netresearch / module-shipping-core

The Netresearch shipping core package is the central component to offer generic functionality as required by all carriers.
Open Software License 3.0
0 stars 1 forks source link

Exception in Netresearch_ShippingCore's `afterValidate` functions #7

Closed simonrl closed 3 months ago

simonrl commented 4 months ago

(this issue was received by the DHL support as DHLSUP-1065519)

Versions

Hi,

we get an error when saving a product. Stacktrace can be seen below.

The error can be solved when removing the : bool from the afterValidate()'s function declaration. As the doc header mentions $result as bool|mixed, I think the : bool isn't correct anyways.

The stacktrace below is from the class ValidateHsCodeAttribute, but we have the same problem with ValidateExportDescriptionAttribute.

Thanks Simon

`TypeError: Netresearch\ShippingCore\Plugin\Eav\Attribute\Backend\ValidateHsCodeAttribute::afterValidate(): Return value must be of type bool, Magento\Weee\Model\Attribute\Backend\Weee\Tax\Interceptor returned in [magento]vendor/netresearch/module-shipping-core/Plugin/Eav/Attribute/Backend/ValidateHsCodeAttribute.php:33 Stack trace:

0 [magento]vendor/magento/framework/Interception/Interceptor.php(146): Netresearch\ShippingCore\Plugin\Eav\Attribute\Backend\ValidateHsCodeAttribute->afterValidate()

1 [magento]vendor/magento/module-configurable-product/Plugin/Model/Attribute/Backend/AttributeValidation.php(57): Magento\Weee\Model\Attribute\Backend\Weee\Tax\Interceptor->Magento\Framework\Interception{closure}()

2 [magento]vendor/magento/framework/Interception/Interceptor.php(135): Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend\AttributeValidation->aroundValidate()

3 [magento]vendor/magento/module-catalog/Plugin/Model/Attribute/Backend/AttributeValidation.php(63): Magento\Weee\Model\Attribute\Backend\Weee\Tax\Interceptor->Magento\Framework\Interception{closure}()

4 [magento]vendor/magento/framework/Interception/Interceptor.php(135): Magento\Catalog\Plugin\Model\Attribute\Backend\AttributeValidation->aroundValidate()

5 [magento]vendor/magento/framework/Interception/Interceptor.php(153): Magento\Weee\Model\Attribute\Backend\Weee\Tax\Interceptor->Magento\Framework\Interception{closure}()

6 [magento]generated/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax/Interceptor.php(23): Magento\Weee\Model\Attribute\Backend\Weee\Tax\Interceptor->___callPlugins()

7 [internal function]: Magento\Weee\Model\Attribute\Backend\Weee\Tax\Interceptor->validate()

8 [magento]vendor/magento/module-eav/Model/Entity/AbstractEntity.php(682): call_user_func_array()

9 [magento]vendor/magento/module-eav/Model/Entity/AbstractEntity.php(877): Magento\Eav\Model\Entity\AbstractEntity->walkAttributes()

10 [magento]vendor/magento/module-catalog/Model/ResourceModel/Product.php(711): Magento\Eav\Model\Entity\AbstractEntity->validate()

11 [magento]vendor/magento/module-catalog/Model/Product.php(565): Magento\Catalog\Model\ResourceModel\Product->validate()

12 [magento]vendor/magento/module-catalog/Model/Product/Validator.php(25): Magento\Catalog\Model\Product->validate()

13 [magento]vendor/magento/framework/Interception/Interceptor.php(58): Magento\Catalog\Model\Product\Validator->validate()

14 [magento]vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Model\Product\Validator\Interceptor->___callParent()

15 [magento]vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\Product\Validator\Interceptor->Magento\Framework\Interception{closure}()

16 [magento]generated/code/Magento/Catalog/Model/Product/Validator/Interceptor.php(22): Magento\Catalog\Model\Product\Validator\Interceptor->___callPlugins()

17 [magento]vendor/magento/module-catalog/Controller/Adminhtml/Product/Validate.php(157): Magento\Catalog\Model\Product\Validator\Interceptor->validate()

18 [magento]vendor/magento/framework/Interception/Interceptor.php(58): Magento\Catalog\Controller\Adminhtml\Product\Validate->execute()

19 [magento]vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->___callParent()

20 [magento]vendor/meta/module-business-extension/Plugin/LoggingPluginBase.php(137): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->Magento\Framework\Interception{closure}()

21 [magento]vendor/meta/module-business-extension/Plugin/LoggingPluginBase.php(85): Meta\BusinessExtension\Plugin\LoggingPluginBase->wrapCallableWithLogging()

22 [magento]vendor/meta/module-business-extension/Plugin/LoggingActionPlugin.php(45): Meta\BusinessExtension\Plugin\LoggingPluginBase->wrapCallableWithErrorAndImpressionLogging()

23 [magento]vendor/magento/framework/Interception/Interceptor.php(135): Meta\BusinessExtension\Plugin\LoggingActionPlugin->aroundExecute()

24 [magento]vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->Magento\Framework\Interception{closure}()

25 [magento]generated/code/Magento/Catalog/Controller/Adminhtml/Product/Validate/Interceptor.php(23): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->___callPlugins()

26 [magento]vendor/magento/framework/App/Action/Action.php(111): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->execute()

27 [magento]vendor/magento/module-backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch()

28 [magento]vendor/magento/framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch()

29 [magento]vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->___callParent()

30 [magento]vendor/magento/module-backend/App/Action/Plugin/Authentication.php(145): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->Magento\Framework\Interception{closure}()

31 [magento]vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch()

32 [magento]vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->Magento\Framework\Interception{closure}()

33 [magento]generated/code/Magento/Catalog/Controller/Adminhtml/Product/Validate/Interceptor.php(32): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->___callPlugins()

34 [magento]vendor/magento/framework/App/FrontController.php(245): Magento\Catalog\Controller\Adminhtml\Product\Validate\Interceptor->dispatch()

35 [magento]vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()

36 [magento]vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()

37 [magento]vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()

38 [magento]vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()

39 [magento]vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}()

40 [magento]generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()

41 [magento]vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()

42 [magento]vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()

43 [magento]vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent()

44 [magento]vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception{closure}()

45 [magento]generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins()

46 [magento]vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()

47 [magento]pub/index.php(30): Magento\Framework\App\Bootstrap->run()

48 {main}`

Sebastian80 commented 4 months ago

Hi @simonrl ,

thank you for reporting the issue, we look into it.

internal Ref: DHLGW-1384

Sebastian80 commented 4 months ago

Hi @simonrl ,

sorry for the delay. I had a look into this and we are not able to reproduce said behavior. The Validator is a after Plugin on \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::validate() which returns bool. According to your stacktrace there is a module Meta\BusinessExtension involved which is not installed in a plain magento. Please try to disable said module and try again. If its working afterwards, you need to figure out what the module is doing, and check if there is an error in the module.

mam08ixo commented 4 months ago

I suspect the Magento_Weee module causing havoc here. If you do not use it, then uninstall it. As @Sebastian80 already mentioned, AbstractBackend::validate() is annotated to return bool and the error is caused by some backend model that returns something else.

czettnersandor commented 3 months ago

@mam08ixo It's not possible to disable the Weee module, because doing so will uninstall the tables for it, then you can't open a product in the admin at all.

The solution is to typecast (bool) like so on line 33:

return (bool) $result;
simonrl commented 3 months ago

Sorry for the delay. We also can't disable the Weee module because we're actually using it. Thanks all, we'll just make a composer patch then.

Sebastian80 commented 3 months ago

Hi @simonrl, we released a new version. The new version is compatible with Magento 2.4.7 and has a fix for your problem. We removed the return type declaration on the afterValidate function.

simonrl commented 3 months ago

Thanks a lot!