owebia / magento2-module-shared-php-config

Other
0 stars 4 forks source link

compatibility issue - php8.1 #7

Closed bohdan-berezhniy closed 1 year ago

bohdan-berezhniy commented 2 years ago

https://site.com/customer/section/load/?sections=messages%2Ccustomer%2Ccompare-products%2Clast-ordered-items%2Ccart%2Cdirectory-data%2Ccaptcha%2Cinstant-purchase%2Cpersistent%2Creview%2Cwishlist%2Cammessages%2Crecently_viewed_product%2Crecently_compared_product%2Cproduct_data_storage%2Cpaypal-billing-agreement&_=1653134965252

TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php:1123 Stack trace:

0 [internal function]: array_map()

1 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(1123): call_user_func_array()

2 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(842): Owebia\SharedPhpConfig\Helper\Evaluator->callFunction()

3 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(416): Owebia\SharedPhpConfig\Helper\Evaluator->evalNodeExprFuncCall()

4 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(1093): Owebia\SharedPhpConfig\Helper\Evaluator->evalNodeExpr()

5 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(1145): Owebia\SharedPhpConfig\Helper\Evaluator->evl()

6 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(841): Owebia\SharedPhpConfig\Helper\Evaluator->evaluateArgs()

7 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(416): Owebia\SharedPhpConfig\Helper\Evaluator->evalNodeExprFuncCall()

8 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(1093): Owebia\SharedPhpConfig\Helper\Evaluator->evalNodeExpr()

9 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(512): Owebia\SharedPhpConfig\Helper\Evaluator->evl()

10 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(407): Owebia\SharedPhpConfig\Helper\Evaluator->evalNodeExprAssign()

11 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(1093): Owebia\SharedPhpConfig\Helper\Evaluator->evalNodeExpr()

12 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(993): Owebia\SharedPhpConfig\Helper\Evaluator->evl()

13 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(1091): Owebia\SharedPhpConfig\Helper\Evaluator->evalNodeStmt()

14 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Evaluator.php(320): Owebia\SharedPhpConfig\Helper\Evaluator->evl()

15 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Config.php(121): Owebia\SharedPhpConfig\Helper\Evaluator->evaluate()

16 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-shared-php-config/Helper/Config.php(102): Owebia\SharedPhpConfig\Helper\Config->parseNode()

17 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-advanced-shipping/Model/Carrier.php(269): Owebia\SharedPhpConfig\Helper\Config->parse()

18 /var/www/clients/client3/web4/web/vendor/owebia/magento2-module-advanced-shipping/Model/Carrier.php(219): Owebia\AdvancedShipping\Model\Carrier->getConfig()

19 /var/www/clients/client3/web4/web/vendor/magento/module-instant-purchase/Model/ShippingMethodChoose/CarrierFinder.php(56): Owebia\AdvancedShipping\Model\Carrier->getAllowedMethods()

20 /var/www/clients/client3/web4/web/vendor/magento/module-instant-purchase/Model/ShippingMethodChoose/CheapestMethodChooser.php(60): Magento\InstantPurchase\Model\ShippingMethodChoose\CarrierFinder->getCarriersForCustomerAddress()

21 /var/www/clients/client3/web4/web/vendor/magento/module-instant-purchase/Model/ShippingMethodChoose/CheapestMethodChooser.php(48): Magento\InstantPurchase\Model\ShippingMethodChoose\CheapestMethodChooser->areShippingMethodsAvailable()

22 /var/www/clients/client3/web4/web/vendor/magento/module-instant-purchase/Model/InstantPurchaseChooser.php(93): Magento\InstantPurchase\Model\ShippingMethodChoose\CheapestMethodChooser->choose()

23 /var/www/clients/client3/web4/web/vendor/magento/module-instant-purchase/CustomerData/InstantPurchase.php(93): Magento\InstantPurchase\Model\InstantPurchaseChooser->getOption()

24 /var/www/clients/client3/web4/web/vendor/magento/module-customer/CustomerData/SectionPool.php(90): Magento\InstantPurchase\CustomerData\InstantPurchase->getSectionData()

25 /var/www/clients/client3/web4/web/vendor/magento/module-customer/CustomerData/SectionPool.php(60): Magento\Customer\CustomerData\SectionPool->getSectionDataByNames()

26 /var/www/clients/client3/web4/web/vendor/magento/module-customer/Controller/Section/Load.php(78): Magento\Customer\CustomerData\SectionPool->getSectionsData()

27 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Customer\Controller\Section\Load->execute()

28 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Controller\Section\Load\Interceptor->___callParent()

29 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Controller\Section\Load\Interceptor->Magento\Framework\Interception{closure}()

30 /var/www/clients/client3/web4/web/generated/code/Magento/Customer/Controller/Section/Load/Interceptor.php(23): Magento\Customer\Controller\Section\Load\Interceptor->___callPlugins()

31 /var/www/clients/client3/web4/web/vendor/magento/framework/App/Action/Action.php(111): Magento\Customer\Controller\Section\Load\Interceptor->execute()

32 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()

33 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Controller\Section\Load\Interceptor->___callParent()

34 /var/www/clients/client3/web4/web/app/code/Apptrian/FacebookPixel/Plugin/App/Action/Context.php(61): Magento\Customer\Controller\Section\Load\Interceptor->Magento\Framework\Interception{closure}()

35 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(135): Apptrian\FacebookPixel\Plugin\App\Action\Context->aroundDispatch()

36 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Controller\Section\Load\Interceptor->Magento\Framework\Interception{closure}()

37 /var/www/clients/client3/web4/web/generated/code/Magento/Customer/Controller/Section/Load/Interceptor.php(32): Magento\Customer\Controller\Section\Load\Interceptor->___callPlugins()

38 /var/www/clients/client3/web4/web/vendor/magento/framework/App/FrontController.php(245): Magento\Customer\Controller\Section\Load\Interceptor->dispatch()

39 /var/www/clients/client3/web4/web/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()

40 /var/www/clients/client3/web4/web/vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()

41 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()

42 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()

43 /var/www/clients/client3/web4/web/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}()

44 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()

45 /var/www/clients/client3/web4/web/vendor/amasty/aminvisiblecaptcha/Plugin/Framework/App/FrontControllerInterface/ValidateCaptcha.php(118): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}()

46 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(135): Amasty\InvisibleCaptcha\Plugin\Framework\App\FrontControllerInterface\ValidateCaptcha->aroundDispatch()

47 /var/www/clients/client3/web4/web/vendor/mirasvit/module-cache-warmer/src/CacheWarmer/Plugin/Debug/OnHitPlugin.php(140): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}()

48 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(135): Mirasvit\CacheWarmer\Plugin\Debug\OnHitPlugin->aroundAroundDispatch()

49 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->Magento\Framework\Interception{closure}()

50 /var/www/clients/client3/web4/web/generated/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin/Interceptor.php(23): Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->___callPlugins()

51 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->aroundDispatch()

52 /var/www/clients/client3/web4/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}()

53 /var/www/clients/client3/web4/web/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()

54 /var/www/clients/client3/web4/web/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()

55 /var/www/clients/client3/web4/web/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()

56 /var/www/clients/client3/web4/web/pub/index.php(30): Magento\Framework\App\Bootstrap->run()

57 {main}

owebia commented 2 years ago

Hi,

This error seams to be related to your configuration.
Could you please post the configuration of the module that you are using?

Best Regards, A.L.

bohdan-berezhniy commented 2 years ago

Hi, you're right. This can be fixed in the extension setting in this way (array)$request->all_items;

But better to return [ ] empty array instead of null. Need to convert $request->all_items a lot of times =(

owebia commented 2 years ago

Hi,

The variable $request->all_items should always be set by Magento.

Are you calling the extension to display the shipping fees on the product page?

In which case is the variable not set?

Best Regards, A.L.

bohdan-berezhniy commented 1 year ago

When I try to login as customer from admin panel

пн, 23 трав. 2022 р. о 21:10 owebia @.***> пише:

Hi,

The variable $request->all_items should always be set by Magento.

Are you calling the extension to display the shipping fees on the product page?

In which case is the variable not set?

Best Regards, A.L.

— Reply to this email directly, view it on GitHub https://github.com/owebia/magento2-module-shared-php-config/issues/7#issuecomment-1134984292, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGIAINSQVQKUYZKWAMH2ZB3VLPCZJANCNFSM5WRYEL2A . You are receiving this because you authored the thread.Message ID: @.***>

owebia commented 1 year ago

Hi,

Can you provide a scenario to reproduce the issue? (including the configuration)

Best Regards, A.L.

Djohn12 commented 1 year ago

Hi there,

I take the liberty to reopen this issue as we are reproducing similar issues regarding php8.1 compatibility inside your module.

Currently using owebia/magento2-module-advanced-shipping 2.8.14 on a Magento 2.4.6 instance.

In its composer.json file, this module requires "owebia/magento2-module-shared-php-config": "^3.0.8" which this morning still resolved to the version 3.0.8.

Using those, we are hitting this error on the cart page and in the magento checkout, on API calls to

method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given in /magento_code/vendor/owebia/magento2-module-shared-php-config/Model/CallbackHandler.php:49

Here is the patch we used to prevent this from happening on our platform.

--- a/Model/CallbackHandler.php
+++ b/Model/CallbackHandler.php (date 1685535534322)
@@ -46,7 +46,7 @@
      */
     public function hasCallback($callback)
     {
-        return method_exists($this, $callback) || method_exists($this->callbackHandlerExtension, $callback);
+        return method_exists($this, $callback) || ($this->callbackHandlerExtension !== null && method_exists($this->callbackHandlerExtension, $callback));
     }

     /**

Best Regards

owebia commented 1 year ago

Hi,

Thanks for your feedback.

$this->callbackHandlerExtension should never be null: https://github.com/owebia/magento2-module-shared-php-config/blob/3.0.8/etc/di.xml#L22

Have you customized our module with overrides or with di.xml?

Best Regards, A.L.

Djohn12 commented 1 year ago

Hi,

Thanks for getting back (and sorry for the delay) !

I confirm we have some historical customizations:

We then use those custom method/variable directly in the back-office carrier config. This helps us simplify the configuration and make it easier to read/understand/modify.

Note that those historical customizations worked fine on all previous versions. This lead me to think the error was indeed due to owebia/magento2-module-shared-php-config source code.

Best Regards