Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BETA]: (beta-2) Configuration page empty after upgrade/Can't save the API key #242

Closed
1 task done
mariuszsienkiewicz opened this issue Apr 18, 2024 · 9 comments · Fixed by #246
Closed
1 task done
Labels
pdk This is a pdk related issue released on @beta released

Comments

@mariuszsienkiewicz
Copy link
Contributor

mariuszsienkiewicz commented Apr 18, 2024

Version check

  • My version of the plugin is v4.0.0-beta.0 or above.

PrestaShop version

8.1.5

PHP version

8.1

What went wrong?

We are currently migrating one of my clients from PrestaShop 1.7 to PrestaShop 8.1.5. Unfortunately, beta-2 isn't working; we are using PHP 8.1.

We tried to upgrade the module via standard way of uploading the zip file in the backoffice but in the result we got an empty module configuration page - no errors in the devtools, it said that admin was rendered sucessfully. In the error.log file I have seen this error:

The class 'MyParcelNL\PrestaShop\Entity\MyparcelnlCartDeliveryOptions' was not found in the chain configured namespaces PrestaShopBundle\Entity, PrestaShop\Module\ProductComment\Entity, PrestaShop\Module\PsAccounts\Entity, MyParcelNL\PrestaShop\Entity\Concern

Whole log can be found below (log ID: 1).

Out of curiosity I've cleaned everything related to the previous version of the plugin (emptied all tables and all configuration related to myparcel module), now configuration page shows at lesat the API key form but it doesn't work because of the similar issue as described above, now it can't find the MyParcelNL\PrestaShop\Entity\MyparcelnlCarrierMapping and this error is now reported even via devtools (log ID: 2).

It seems there's an issue with class autoloading and the compiled container in the module and PDK.

Reproduction steps

Described above.

Relevant log output

Log 1:

*ERROR* 	v8.1.5	2024/04/18 - 09:32:47: [PDK]: The class 'MyParcelNL\PrestaShop\Entity\MyparcelnlCartDeliveryOptions' was not found in the chain configured namespaces PrestaShopBundle\Entity, PrestaShop\Module\ProductComment\Entity, PrestaShop\Module\PsAccounts\Entity, MyParcelNL\PrestaShop\Entity\Concern
{
    "trace": [
        {
            "file": "\/psroot\/vendor\/doctrine\/persistence\/src\/Persistence\/Mapping\/Driver\/MappingDriverChain.php",
            "line": 89,
            "function": "classNotFoundInNamespaces",
            "class": "Doctrine\\Persistence\\Mapping\\MappingException",
            "type": "::"
        },
        {
            "file": "\/psroot\/vendor\/doctrine\/orm\/lib\/Doctrine\/ORM\/Mapping\/ClassMetadataFactory.php",
            "line": 133,
            "function": "loadMetadataForClass",
            "class": "Doctrine\\Persistence\\Mapping\\Driver\\MappingDriverChain",
            "type": "->"
        },
        {
            "file": "\/psroot\/vendor\/doctrine\/persistence\/src\/Persistence\/Mapping\/AbstractClassMetadataFactory.php",
            "line": 343,
            "function": "doLoadMetadata",
            "class": "Doctrine\\ORM\\Mapping\\ClassMetadataFactory",
            "type": "->"
        },
        {
            "file": "\/psroot\/vendor\/doctrine\/persistence\/src\/Persistence\/Mapping\/AbstractClassMetadataFactory.php",
            "line": 207,
            "function": "loadMetadata",
            "class": "Doctrine\\Persistence\\Mapping\\AbstractClassMetadataFactory",
            "type": "->"
        },
        {
            "file": "\/psroot\/vendor\/doctrine\/orm\/lib\/Doctrine\/ORM\/EntityManager.php",
            "line": 313,
            "function": "getMetadataFor",
            "class": "Doctrine\\Persistence\\Mapping\\AbstractClassMetadataFactory",
            "type": "->"
        },
        {
            "file": "\/psroot\/vendor\/doctrine\/doctrine-bundle\/Repository\/ContainerRepositoryFactory.php",
            "line": 40,
            "function": "getClassMetadata",
            "class": "Doctrine\\ORM\\EntityManager",
            "type": "->"
        },
        {
            "file": "\/psroot\/vendor\/doctrine\/orm\/lib\/Doctrine\/ORM\/EntityManager.php",
            "line": 816,
            "function": "getRepository",
            "class": "Doctrine\\Bundle\\DoctrineBundle\\Repository\\ContainerRepositoryFactory",
            "type": "->"
        },
        {
            "file": "\/psroot\/var\/cache\/prod\/Container7ItU0TU\/EntityManager_9a5be93.php",
            "line": 153,
            "function": "getRepository",
            "class": "Doctrine\\ORM\\EntityManager",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/src\/Repository\/AbstractPsObjectRepository.php",
            "line": 35,
            "function": "getRepository",
            "class": "EntityManager_9a5be93",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ObjectCreator.php",
            "line": 112,
            "function": "__construct",
            "class": "MyParcelNL\\PrestaShop\\Repository\\AbstractPsObjectRepository",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ObjectCreator.php",
            "line": 62,
            "function": "createInstance",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ObjectCreator",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 63,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ObjectCreator",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 321,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 116,
            "function": "resolveDefinition",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Reference.php",
            "line": 45,
            "function": "get",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 60,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Reference",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ParameterResolver.php",
            "line": 62,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ObjectCreator.php",
            "line": 111,
            "function": "resolveParameters",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ParameterResolver",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ObjectCreator.php",
            "line": 62,
            "function": "createInstance",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ObjectCreator",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 63,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ObjectCreator",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 321,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 116,
            "function": "resolveDefinition",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Reference.php",
            "line": 45,
            "function": "get",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 60,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Reference",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 321,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 116,
            "function": "resolveDefinition",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Reference.php",
            "line": 45,
            "function": "get",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 60,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Reference",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ParameterResolver.php",
            "line": 62,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ObjectCreator.php",
            "line": 111,
            "function": "resolveParameters",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ParameterResolver",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ObjectCreator.php",
            "line": 62,
            "function": "createInstance",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ObjectCreator",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 63,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ObjectCreator",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 321,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 116,
            "function": "resolveDefinition",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Reference.php",
            "line": 45,
            "function": "get",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 60,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Reference",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 321,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 116,
            "function": "resolveDefinition",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Reference.php",
            "line": 45,
            "function": "get",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 60,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Reference",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ParameterResolver.php",
            "line": 62,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ObjectCreator.php",
            "line": 111,
            "function": "resolveParameters",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ParameterResolver",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ObjectCreator.php",
            "line": 62,
            "function": "createInstance",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ObjectCreator",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Definition\/Resolver\/ResolverDispatcher.php",
            "line": 63,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ObjectCreator",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 321,
            "function": "resolve",
            "class": "_MyParcelNL\\DI\\Definition\\Resolver\\ResolverDispatcher",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/php-di\/php-di\/src\/Container.php",
            "line": 116,
            "function": "resolveDefinition",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Base\/Pdk.php",
            "line": 61,
            "function": "get",
            "class": "_MyParcelNL\\DI\\Container",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Base\/Facade.php",
            "line": 26,
            "function": "get",
            "class": "MyParcelNL\\Pdk\\Base\\Pdk",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Context\/Model\/PluginSettingsViewContext.php",
            "line": 40,
            "function": "__callStatic",
            "class": "MyParcelNL\\Pdk\\Base\\Facade",
            "type": "::"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Context\/Service\/ContextService.php",
            "line": 77,
            "function": "__construct",
            "class": "MyParcelNL\\Pdk\\Context\\Model\\PluginSettingsViewContext",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Context\/Service\/ContextService.php",
            "line": 131,
            "function": "createPluginSettingsViewContext",
            "class": "MyParcelNL\\Pdk\\Context\\Service\\ContextService",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Context\/Service\/ContextService.php",
            "line": 44,
            "function": "resolveContext",
            "class": "MyParcelNL\\Pdk\\Context\\Service\\ContextService",
            "type": "->"
        },
        {
            "function": "MyParcelNL\\Pdk\\Context\\Service\\{closure}",
            "class": "MyParcelNL\\Pdk\\Context\\Service\\ContextService",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Context\/Service\/ContextService.php",
            "line": 46,
            "function": "array_reduce"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Frontend\/Service\/FrontendRenderService.php",
            "line": 214,
            "function": "createContexts",
            "class": "MyParcelNL\\Pdk\\Context\\Service\\ContextService",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Frontend\/Service\/FrontendRenderService.php",
            "line": 201,
            "function": "renderTemplate",
            "class": "MyParcelNL\\Pdk\\Frontend\\Service\\FrontendRenderService",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Frontend\/Service\/FrontendRenderService.php",
            "line": 148,
            "function": "renderComponent",
            "class": "MyParcelNL\\Pdk\\Frontend\\Service\\FrontendRenderService",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/vendor\/myparcelnl\/pdk\/src\/Base\/Facade.php",
            "line": 26,
            "function": "renderPluginSettings",
            "class": "MyParcelNL\\Pdk\\Frontend\\Service\\FrontendRenderService",
            "type": "->"
        },
        {
            "file": "\/psroot\/modules\/myparcelnl\/src\/Controller\/SettingsController.php",
            "line": 18,
            "function": "__callStatic",
            "class": "MyParcelNL\\Pdk\\Base\\Facade",
            "type": "::"
        },
        {
            "file": "\/psroot\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php",
            "line": 169,
            "function": "index",
            "class": "MyParcelNL\\PrestaShop\\Controller\\SettingsController",
            "type": "->"
        },
        {
            "file": "\/psroot\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php",
            "line": 81,
            "function": "handleRaw",
            "class": "Symfony\\Component\\HttpKernel\\HttpKernel",
            "type": "->"
        },
        {
            "file": "\/psroot\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/Kernel.php",
            "line": 201,
            "function": "handle",
            "class": "Symfony\\Component\\HttpKernel\\HttpKernel",
            "type": "->"
        },
        {
            "file": "\/psroot\/admin-dev\/index.php",
            "line": 84,
            "function": "handle",
            "class": "Symfony\\Component\\HttpKernel\\Kernel",
            "type": "->"
        }
    ],
    "template": "<div\n  data-pdk-context=\"__CONTEXT__\"\n  id=\"__ID__\"><\/div>\n<script id=\"__ID__-script\">\n(() => {\n  var e = '__EVENT_PONG__';\n  var listener = function(event) {\n    event.detail.render('__COMPONENT__', '#__ID__');\n    document.getElementById('__ID__-script').remove();\n    document.removeEventListener(e, listener);\n  };\n\n  document.addEventListener(e, listener);\n  document.dispatchEvent(new Event('__EVENT_PING__'));\n})();\n<\/script>\n",
    "contexts": [
        "pluginSettingsView"
    ],
    "templateParameters": {
        "__ID__": "pdk-plugin-settings-837138776",
        "__COMPONENT__": "PluginSettings",
        "__EVENT_PING__": "myparcel_pdk_ping",
        "__EVENT_PONG__": "myparcel_pdk_pong"
    },
    "contextArguments": []
}

Log 2:

accountUpdateERROR handler ApiException: The class 'MyParcelNL\PrestaShop\Entity\MyparcelnlCarrierMapping' was not found in the chain configured namespaces PrestaShopBundle\Entity, PrestaShop\Module\ProductComment\Entity, PrestaShop\Module\PsAccounts\Entity, MyParcelNL\PrestaShop\Entity\Concern
at Sg.doRequest (https://domain.example/modules/myparcelnl/views/js/backend/admin/dist/index.iife.js:21:55600)
at async Object.Ce [as mutationFn] (https://domain.example/modules/myparcelnl/views/js/backend/admin/dist/index.iife.js:21:56772)

Additional context

No response

@mariuszsienkiewicz mariuszsienkiewicz added the pdk This is a pdk related issue label Apr 18, 2024
@RedFuseCap
Copy link

Same issue here. In my case on PrestaShop version 8.1.4 and PHP version 8.1.
After installing the module, the configuration page of the module is completely empty.

When I cleared the cache and removed all MyParcel related rows in ps_configuration, the configuration page of the module gives the option to enter the API-key.
After pasting the correct API key and clicking "Save", I get an error about an invalid API key.
Symphony Profiler shows an 400 error at that point for the following path: /modules/myparcelnl/pdk?action=updateAccount
When refreshing the configuration page of the module, it is completely empty again.

Looking in the database within the ps_configuration table after these actions, new rows related to MyParcel are generated again.
The "myparcelnl_data_account" config item in this table, shows specific data from MyParcel backend, meaning the API key did work.

@RedFuseCap
Copy link

RedFuseCap commented Apr 22, 2024

@mariuszsienkiewicz Thanks for the detailed reaction.

Looking at the error logfile in the <ps_root>/var/log/myparcelnl folder, I get similar output as your log 1 output. It starts with the following line:

ERROR v8.1.4 2024/04/22 - 21:58:43: [PDK]: The class 'MyParcelNL\PrestaShop\Entity\MyparcelnlCartDeliveryOptions' was not found in the chain configured namespaces PrestaShopBundle\Entity, PrestaShop\Module\ProductComment\Entity, MyParcelNL\PrestaShop\Entity\Concern

I use English as default language. In addition, we offer Dutch language. As far as I can see, the nl.json should be used in case of Dutch language and looks fine.

@mariuszsienkiewicz
Copy link
Contributor Author

@RedFuseCap I've encountered so many issues with this module that I've started mixing up their symptoms! 😄 I completely forgot that I had mentioned clearing the configuration and the API key form appearing and that's why I thought that your issue is a little bit different haha. I've deleted my previous comment. Sorry for any confusion!

@mariuszsienkiewicz
Copy link
Contributor Author

mariuszsienkiewicz commented Apr 23, 2024

@EdieLemoine I did the hard work to find the reason for this issue (which is probably the same as #235) - and as you can probably see, it's not that "rare". It just won't work on some servers, and that's why I think it should be fixed.

Detailed explanation of the issue

The gray page is caused by the problem that Doctrine can't find the proper namespace. As you have seen in the description of this issue, it looks in those namespaces PrestaShopBundle\Entity, PrestaShop\Module\ProductComment\Entity, PrestaShop\Module\PsAccounts\Entity, and MyParcelNL\PrestaShop\Entity\Concern.

The reason why MyParcelNL\PrestaShop\Entity\Concern is in the chain but MyParcelNL\PrestaShop\Entity is not, is because the PrestaShop compiler does not explicitly support defining subnamespaces at all in the <module>/src/Entity directory:

https://github.com/PrestaShop/PrestaShop/blob/1f3b8d0760470700b792887ebe4d9cc0d4f82625/src/PrestaShopBundle/DependencyInjection/Compiler/ModulesDoctrineCompilerPass.php#L121-L133

It just finds the namespace of the first file (that is provided by Finder - this class will be important later) that has the "namespace" text in it.

So here is a catch - Finder uses the RecursiveDirectoryIterator which uses internally (as far as I know) the opendir function. The latter one has no guarantee how the files will be returned - and it will differ on different servers (kernels) etc. (php version doesn't matter).

For example, on one of the servers that I use, the Finder used above returns files in this order:

<ps_root>/modules/myparcelnl/src/Entity/Concern/HasJsonData.php
<ps_root>/modules/myparcelnl/src/Entity/Concern/HasCreatedTimestamps.php
<ps_root>/modules/myparcelnl/src/Entity/Concern/HasTimestamps.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityWithCreatedTimestampsInterface.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityWithTimestampsInterface.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityInterface.php
<ps_root>/modules/myparcelnl/src/Entity/MyparcelnlOrderData.php
<ps_root>/modules/myparcelnl/src/Entity/MyparcelnlAudit.php
...

But on the other server (where the module works), it returns:

<ps_root>/modules/myparcelnl/src/Entity/MyparcelnlOrderShipment.php
<ps_root>/modules/myparcelnl/src/Entity/MyparcelnlProductSettings.php
<ps_root>/modules/myparcelnl/src/Entity/MyparcelnlCarrierMapping.php
<ps_root>/modules/myparcelnl/src/Entity/MyparcelnlOrderData.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityWithTimestampsInterface.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityWithCreatedTimestampsInterface.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityInterface.php
<ps_root>/modules/myparcelnl/src/Entity/AbstractEntity.php
...

So on the server where it's not working, Finder finds the MyParcelNL\PrestaShop\Entity\Concern first and treats it like a namespace that should be put in the Doctrine namespace chain instead of MyParcelNL\PrestaShop\Entity.

That's why it does not work for me and other people. Clearing cache changes nothing because it doesn't affect how the internal files are being returned to the function.

Fix suggestions

For now, I see only two fixes here to make the module more compatible:


@RedFuseCap could you please check if this issue is similar to yours? Below you can find the code that will display the order of files that are being loaded via PrestaShop Compiler. Just create a new php file in the root folder of PrestaShop and run it via a web browser:

<?php

require_once 'vendor/autoload.php';

use Symfony\Component\Finder\Finder;

$dir = __DIR__ . '/modules/myparcelnl';

// finder
$finder = new Finder();
$finder->files()->in($dir . '/src/Entity')->name('*.php');
echo "<pre>";
foreach ($finder as $phpFile) {
    echo sprintf("file/dir: %s%s", $phpFile, PHP_EOL);
}
echo "</pre>";

// direct use of recursiveIteratorIterator
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir . '/src/Entity'));
echo "<pre>";
/** @var \SplFileObject $spl $ */
foreach ($it as $spl) {
    echo sprintf("file/dir: %s%s", $spl->getFilename(), PHP_EOL);
}
echo "</pre>";

// direct use of opendir
echo "<pre>";
if ($directoryHandler = opendir($dir . '/src/Entity')) {
    while (($file = readdir($directoryHandler)) !== false) {
        echo sprintf("file/dir: %s%s", $file, PHP_EOL);
    }
    closedir($dh);
}
echo "</pre>";

@RedFuseCap
Copy link

This is the output on my server:

<ps_root>/modules/myparcelnl/src/Entity/Concern/HasJsonData.php
<ps_root>/modules/myparcelnl/src/Entity/Concern/HasTimestamps.php
<ps_root>/modules/myparcelnl/src/Entity/Concern/HasCreatedTimestamps.php
<ps_root>/modules/myparcelnl/src/Entity/AbstractEntity.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityInterface.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityWithTimestampsInterface.php
<ps_root>/modules/myparcelnl/src/Entity/Contract/EntityWithCreatedTimestampsInterface.php
<ps_root>/modules/myparcelnl/src/Entity/MyparcelnlCartDeliveryOptions.php
<ps_root>/modules/myparcelnl/src/Entity/MyparcelnlProductSettings.php
...

@mariuszsienkiewicz
Copy link
Contributor Author

Thank you @RedFuseCap! This confirms that the file order is indeed different and is related to the environment. We are now waiting for the devs input.

@EdieLemoine
Copy link
Member

Hi @mariuszsienkiewicz and @RedFuseCap,

Thank you for figuring out what this is caused by! This happens a lot on our test environments as well and for us is actually solved by clearing the cache, but we've (incorrectly) assumed it's not a problem for customers. It used to regularly happen on the previous version of the module as well, but customers did not report it happening, so we figured it must be the same thing.

Again thanks @mariuszsienkiewicz for the hard work! 😄 I'll shortly make a pull request (unless you want to get credit for contributing) that moves the classes to the same directory, I hope that finally resolves this issue.

EdieLemoine added a commit that referenced this issue Apr 24, 2024
Resolves #242

Co-authored-by: Mariusz Sienkiewicz <mariusz.sienkiewicz.it@gmail.com>
github-merge-queue bot pushed a commit that referenced this issue Apr 26, 2024
Resolves #242

Co-authored-by: Mariusz Sienkiewicz <mariusz.sienkiewicz.it@gmail.com>
EdieLemoine added a commit that referenced this issue May 1, 2024
Resolves #242

Co-authored-by: Mariusz Sienkiewicz <mariusz.sienkiewicz.it@gmail.com>
myparcel-bot bot added a commit that referenced this issue May 1, 2024
## [4.0.0-beta.3](v4.0.0-beta.2...v4.0.0-beta.3) (2024-05-01)

### 🐛 Bug Fixes

* **checkout:** remove missing style.css error ([a382771](a382771))
* fix namespace error when installing module ([#246](#246)) ([cf3c9e4](cf3c9e4)), closes [#242](#242)
* **install:** fix upgrading from older versions ([#245](#245)) ([ae3b626](ae3b626)), closes [#243](#243)
* **migration:** fix errors when invalid db data is returned ([#252](#252)) ([00bc56e](00bc56e))
* **migration:** prevent $row must be array but bool supplied during installation ([#241](#241)) ([b655806](b655806))

### ✨ New Features

* **deps:** upgrade @myparcel-pdk/* ([86a1c1c](86a1c1c))
* **deps:** upgrade myparcelnl/pdk to v2.36.2 ([a1a9a57](a1a9a57))
* update to latest delivery options ([#240](#240)) ([82064fa](82064fa))
@myparcel-bot
Copy link
Contributor

myparcel-bot bot commented May 1, 2024

🎉 This issue has been resolved in version 4.0.0-beta.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

myparcel-bot bot added a commit that referenced this issue Oct 16, 2024
## [4.0.0](v3.10.0...v4.0.0) (2024-10-16)

### ⚠ BREAKING CHANGES

* implement pdk

### 🐛 Bug Fixes

* **account:** fix carrier mapping constraint error on account update ([21eb32f](21eb32f))
* **admin:** fix all inputs appearing as required ([142f9f9](142f9f9))
* **admin:** fix broken import ([0c1c1ad](0c1c1ad))
* **admin:** fix error on pages without bulk actions ([9960cee](9960cee))
* **admin:** fix scripts ([9c4ef00](9c4ef00))
* **admin:** improve product settings appearance ([5682b73](5682b73))
* **admin:** improve product settings form ([84714ce](84714ce))
* **admin:** improve tri state input appearance ([d8186c7](d8186c7))
* **admin:** remove required indicators from inputs ([3e5bff7](3e5bff7))
* **admin:** update components ([8e73009](8e73009))
* **carriers:** add carrier migration and improve logic ([7e08891](7e08891))
* **carrier:** set human as name instead of identifier ([c040806](c040806))
* **carriers:** fix carriers and payment methods not being linked ([2228f71](2228f71))
* **carriers:** update carrier creation logic ([dee2d3f](dee2d3f))
* **carriers:** update default values ([63d3077](63d3077))
* **cart:** use correct value for country ([#263](#263)) ([7fb25cc](7fb25cc))
* **checkout:** do not load delivery options script if it's disabled ([713f566](713f566))
* **checkout:** fix delivery options not loading in ps 1.7 ([#270](#270)) ([11c6a46](11c6a46))
* **checkout:** fix incorrect shipping price being used in checkout ([#272](#272)) ([eebdfd5](eebdfd5))
* **checkout:** fix saving delivery options to cart ([64e9e86](64e9e86))
* **checkout:** improve delivery options logic ([6d3fa93](6d3fa93))
* **checkout:** remove missing style.css error ([a382771](a382771))
* **checkout:** retain specific configs when switching carriers ([3d3c223](3d3c223))
* **checkout:** update checkout ([7714efd](7714efd))
* **checkout:** update checkout hooks ([0297ce0](0297ce0))
* **core:** improve core module error handling ([b15ed15](b15ed15))
* **database:** allow creating index to fail if sql functionality is not supported ([6550654](6550654))
* **database:** fix creating indexes on certain db drivers ([fbbc611](fbbc611))
* **database:** fix database indexes and keys ([5ddb09d](5ddb09d))
* **database:** only create indexes if they do not exist ([33b89fd](33b89fd))
* **deps:** upgrade myparcelnl/pdk to v2.30.3 ([26c6bc5](26c6bc5))
* **deps:** upgrade myparcelnl/pdk to v2.30.4 ([217c239](217c239))
* **deps:** upgrade myparcelnl/pdk to v2.31.2 ([2309ea4](2309ea4))
* **entity:** update entities ([5d415e8](5d415e8))
* fix di container in production mode ([49874fc](49874fc))
* fix error when exception has no previous exception ([#260](#260)) ([68f051f](68f051f))
* fix error when loading webhook subscriptions ([7fab71c](7fab71c))
* fix namespace error when installing module ([#246](#246)) ([cf3c9e4](cf3c9e4)), closes [#242](#242)
* fix path to log directory ([0bef829](0bef829))
* fix php errors ([8ab2f49](8ab2f49))
* **fulfilment:** add order notes ([e14fa32](e14fa32))
* improve entities ([275265e](275265e))
* improve entities and carrier logic ([b61d197](b61d197))
* improve installation logging ([056aca4](056aca4))
* improve stability of installation flow ([8db8654](8db8654))
* include state code in address for ups ([#276](#276)) ([e89a2f5](e89a2f5))
* increase max ps version to 8.2 ([ffb2732](ffb2732))
* install module tab correctly ([19d3b33](19d3b33))
* **installer:** clear sf2 cache on install ([533cda0](533cda0))
* **installer:** fix prestashop context error on install ([003ca3b](003ca3b))
* **installer:** prepare the ps entity manager before starting ([016c9ee](016c9ee))
* **installer:** properly delete account on uninstall ([bdf1d3a](bdf1d3a))
* **installer:** save the installed version to database ([3f067f0](3f067f0))
* **install:** fix upgrading from older versions ([#245](#245)) ([ae3b626](ae3b626)), closes [#243](#243)
* **logger:** fix logger ([3ef0b51](3ef0b51))
* **logging:** improve logging ([0caa9ef](0caa9ef))
* **logging:** include context in logs ([fc0723e](fc0723e))
* **logging:** update log format ([e015767](e015767))
* **migration:** fix db constraint errors in migrations ([7ebc855](7ebc855))
* **migration:** fix errors when invalid db data is returned ([#252](#252)) ([00bc56e](00bc56e))
* **migration:** fix type error ([12f4fad](12f4fad))
* **migration:** fix type error in product settings migration ([a7a32b2](a7a32b2)), closes [#235](#235)
* **migration:** fix type error when input is not an array ([#262](#262)) ([d40d6df](d40d6df))
* **migration:** harden error handling ([b75d277](b75d277))
* **migration:** improve order shipments migration ([f6f3b5e](f6f3b5e))
* **migration:** improve settings migration ([cc9e21c](cc9e21c))
* **migration:** improve settings migration ([2aa8da9](2aa8da9))
* **migration:** migrate migrations ([0263e9f](0263e9f))
* **migration:** prevent $row must be array but bool supplied during installation ([#241](#241)) ([b655806](b655806))
* **migration:** run migrations when upgrading ([7534da7](7534da7))
* **migrations:** improve migrations ([148fceb](148fceb))
* **migration:** update and test shipments migration ([f0f33ca](f0f33ca))
* **module:** move settings to dedicated page ([138ed5c](138ed5c))
* **order:** fix errors caused by missing dates ([54bfc96](54bfc96))
* **order:** fix saving data to orders ([cb3dbd9](cb3dbd9))
* **orders:** fix error when weight is a string ([#261](#261)) ([9e844a2](9e844a2)), closes [#256](#256)
* **orders:** move order note logic to order note repository ([9b83b32](9b83b32))
* **orders:** prevent order id type error ([e59ab3c](e59ab3c))
* **orders:** reset index on collection ([5e92f23](5e92f23))
* **orders:** throw error on getting nonexistent order ([f0921ee](f0921ee))
* **orders:** trim whitespace in person field ([2ab31a4](2ab31a4))
* pass dev mode to bootstrapper ([ca5d58b](ca5d58b))
* prevent integrity constraint violation for notes column ([#259](#259)) ([53c5eab](53c5eab))
* **products:** fix product settings logic and migration ([96734a1](96734a1))
* **products:** fix saving product settings ([b6e3c89](b6e3c89))
* **products:** improve handling of nonexistent products ([#229](#229)) ([efd8483](efd8483)), closes [#228](#228)
* remove deprecation warning ([ade1951](ade1951))
* **scripts:** improve script loading logic ([878403a](878403a))
* **settings:** improve saving settings ([b313793](b313793))
* **settings:** remove settings that aren't available ([d413ff1](d413ff1))
* **upgrade:** fix reference to facade class ([b580ffb](b580ffb))
* **webhooks:** fix webhooks ([dad3abc](dad3abc))

### ✨ New Features

* **admin:** improve admin component appearance ([e97ccc3](e97ccc3))
* **admin:** improve look of components ([2df8009](2df8009))
* **carriers:** add carrier logos ([1ae56e6](1ae56e6))
* **carriers:** allow changing name and delivery speed texts ([ea19255](ea19255))
* **checkout:** calculate shipping costs per carrier ([e03a380](e03a380))
* **deps:** upgrade @myparcel-pdk/* ([781600d](781600d))
* **deps:** upgrade @myparcel-pdk/* ([687ecb3](687ecb3))
* **deps:** upgrade @myparcel-pdk/* ([86a1c1c](86a1c1c))
* **deps:** upgrade @myparcel-pdk/* ([2c88f49](2c88f49))
* **deps:** upgrade @myparcel-pdk/* ([36cdc62](36cdc62))
* **deps:** upgrade myparcelnl/pdk to v2.30.2 ([885ead1](885ead1))
* **deps:** upgrade myparcelnl/pdk to v2.31.0 ([f830d7b](f830d7b))
* **deps:** upgrade myparcelnl/pdk to v2.33.2 ([1bd9d5d](1bd9d5d))
* **deps:** upgrade myparcelnl/pdk to v2.36.2 ([a1a9a57](a1a9a57))
* **deps:** upgrade myparcelnl/pdk to v2.42.0 ([d3f1a78](d3f1a78))
* **deps:** upgrade myparcelnl/pdk to v2.43.5 ([f9b206d](f9b206d))
* **frontend:** allow html in form descriptions ([#257](#257)) ([1251164](1251164))
* **fulfilment:** add order notes ([ae98602](ae98602))
* implement pdk ([c497eb8](c497eb8))
* **logging:** improve logging output ([861e713](861e713))
* **order-grid:** add bulk order actions ([53b2a63](53b2a63))
* **order:** implement updating order notes ([935955d](935955d))
* **orders:** implement automatic order status updates ([9af8725](9af8725))
* **settings:** enable/disable carriers based on settings ([7f558a4](7f558a4))
* **settings:** implement shipping method repository ([045a668](045a668))
* support prestashop 1.7 ([#239](#239)) ([b16926c](b16926c)), closes [#232](#232)
* update to latest delivery options ([#240](#240)) ([82064fa](82064fa))
* upgrade to delivery options v6.x ([35d2b05](35d2b05))
@myparcel-bot
Copy link
Contributor

myparcel-bot bot commented Oct 16, 2024

🎉 This issue has been resolved in version 4.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pdk This is a pdk related issue released on @beta released
Development

Successfully merging a pull request may close this issue.

3 participants