Hi all,
What a headache.. we migrated the orders to our new M2.3.5 website. They are giving now serialize issues. Any tips or hints?
1 exception(s): Exception #0 (InvalidArgumentException): Unable to unserialize value. Error: Syntax error Exception #0 (InvalidArgumentException): Unable to unserialize value. Error: Syntax error <pre>#1 Magento\Framework\Model\ResourceModel\AbstractResource->_unserializeField() called at [vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:511] #2 Magento\Framework\Model\ResourceModel\Db\AbstractDb->unserializeFields() called at [vendor/magento/module-sales/Model/ResourceModel/Order/Item/Collection.php:62] #3 Magento\Sales\Model\ResourceModel\Order\Item\Collection->_afterLoad() called at [vendor/magento/framework/Data/Collection/AbstractDb.php:594] #4 Magento\Framework\Data\Collection\AbstractDb->loadWithFilter() called at [vendor/magento/framework/Data/Collection/AbstractDb.php:565] #5 Magento\Framework\Data\Collection\AbstractDb->load() called at [vendor/magento/framework/Data/Collection.php:333] #6 Magento\Framework\Data\Collection->getItems() called at [vendor/magento/module-sales/Model/Order/ItemRepository.php:129] #7 Magento\Sales\Model\Order\ItemRepository->getList() called at [vendor/magento/module-sales/Model/Order.php:2141] #8 Magento\Sales\Model\Order->getItems() called at [generated/code/Magento/Sales/Model/Order/Interceptor.php:1259] #9 Magento\Sales\Model\Order\Interceptor->getItems() called at [vendor/magento/module-sales/Model/Order/ShippingAssignmentBuilder.php:86] #10 Magento\Sales\Model\Order\ShippingAssignmentBuilder->create() called at [vendor/magento/module-sales/Model/OrderRepository.php:294] #11 Magento\Sales\Model\OrderRepository->setShippingAssignments() called at [vendor/magento/module-sales/Model/OrderRepository.php:144] #12 Magento\Sales\Model\OrderRepository->get() called at [vendor/magento/framework/Interception/Interceptor.php:58] #13 Magento\Sales\Model\OrderRepository\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #14 Magento\Sales\Model\OrderRepository\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #15 Magento\Sales\Model\OrderRepository\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Model/OrderRepository/Interceptor.php:26] #16 Magento\Sales\Model\OrderRepository\Interceptor->get() called at [vendor/magento/module-sales/Controller/Adminhtml/Order.php:155] #17 Magento\Sales\Controller\Adminhtml\Order->_initOrder() called at [vendor/magento/module-sales/Controller/Adminhtml/Order/View.php:26] #18 Magento\Sales\Controller\Adminhtml\Order\View->execute() called at [vendor/magento/framework/App/Action/Action.php:108] #19 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:231] #20 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #21 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #22 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143] #23 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] #24 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #25 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Controller/Adminhtml/Order/View/Interceptor.php:26] #26 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:162] #27 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:98] #28 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #29 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #30 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #31 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26] #32 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116] #33 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24] #34 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261] #35 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40] </pre>
Solved! Go to Solution.
Hi Bhanu,
I replaced that function with your suggestion. It's returning a different error now.
1 exception(s): Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /data/web/magento2/vendor/magento/module-sales/Model/OrderRepository.php on line 186 Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /data/web/magento2/vendor/magento/module-sales/Model/OrderRepository.php on line 186 <pre>#1 Magento\Sales\Model\OrderRepository->setPaymentAdditionalInfo() called at [vendor/magento/module-sales/Model/OrderRepository.php:145] #2 Magento\Sales\Model\OrderRepository->get() called at [vendor/magento/framework/Interception/Interceptor.php:58] #3 Magento\Sales\Model\OrderRepository\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #4 Magento\Sales\Model\OrderRepository\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #5 Magento\Sales\Model\OrderRepository\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Model/OrderRepository/Interceptor.php:26] #6 Magento\Sales\Model\OrderRepository\Interceptor->get() called at [vendor/magento/module-sales/Controller/Adminhtml/Order.php:155] #7 Magento\Sales\Controller\Adminhtml\Order->_initOrder() called at [vendor/magento/module-sales/Controller/Adminhtml/Order/View.php:26] #8 Magento\Sales\Controller\Adminhtml\Order\View->execute() called at [vendor/magento/framework/App/Action/Action.php:108] #9 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:231] #10 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #11 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #12 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143] #13 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] #14 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #15 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Controller/Adminhtml/Order/View/Interceptor.php:26] #16 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:162] #17 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:98] #18 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #19 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #20 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #21 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26] #22 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116] #23 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24] #24 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261] #25 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40] </pre>
Hi @Bierkelder
To solve this, go to
\vendor\magento\framework\Serialize\Serializer\json.php
and replace the below function as mention below:
public function unserialize($string) { if($this->is_serialized($string)) { $string = $this->serialize($string); } $result = json_decode($string, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new \InvalidArgumentException('Unable to unserialize value.'); } return $result; } function is_serialized($value, &$result = null) { // Bit of a give away this one if (!is_string($value)) { return false; } // Serialized false, return true. unserialize() returns false on an // invalid string or it could return false if the string is serialized // false, eliminate that possibility. if ($value === 'b:0;') { $result = false; return true; } $length = strlen($value); $end = ''; switch ($value[0]) { case 's': if ($value[$length - 2] !== '"') { return false; } case 'b': case 'i': case 'd': // This looks odd but it is quicker than isset()ing $end .= ';'; case 'a': case 'O': $end .= '}'; if ($value[1] !== ':') { return false; } switch ($value[2]) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: break; default: return false; } case 'N': $end .= ';'; if ($value[$length - 1] !== $end[0]) { return false; } break; default: return false; } if (($result = @unserialize($value)) === false) { $result = null; return false; } return true; }
It may help you to resolve issue.
If issue resolve, please click on 'Kudos' & Accept as Solution!
Hi Bhanu,
I replaced that function with your suggestion. It's returning a different error now.
1 exception(s): Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /data/web/magento2/vendor/magento/module-sales/Model/OrderRepository.php on line 186 Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /data/web/magento2/vendor/magento/module-sales/Model/OrderRepository.php on line 186 <pre>#1 Magento\Sales\Model\OrderRepository->setPaymentAdditionalInfo() called at [vendor/magento/module-sales/Model/OrderRepository.php:145] #2 Magento\Sales\Model\OrderRepository->get() called at [vendor/magento/framework/Interception/Interceptor.php:58] #3 Magento\Sales\Model\OrderRepository\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #4 Magento\Sales\Model\OrderRepository\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #5 Magento\Sales\Model\OrderRepository\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Model/OrderRepository/Interceptor.php:26] #6 Magento\Sales\Model\OrderRepository\Interceptor->get() called at [vendor/magento/module-sales/Controller/Adminhtml/Order.php:155] #7 Magento\Sales\Controller\Adminhtml\Order->_initOrder() called at [vendor/magento/module-sales/Controller/Adminhtml/Order/View.php:26] #8 Magento\Sales\Controller\Adminhtml\Order\View->execute() called at [vendor/magento/framework/App/Action/Action.php:108] #9 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:231] #10 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #11 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #12 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143] #13 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135] #14 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #15 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Controller/Adminhtml/Order/View/Interceptor.php:26] #16 Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:162] #17 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:98] #18 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58] #19 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138] #20 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153] #21 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26] #22 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116] #23 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24] #24 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261] #25 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40] </pre>
To add to this, for invoices, it's working now (had same serialize issue). So partially solved already!
Thanks or the detailed information
Hi Bhanu,
Fixed the other issue by using - https://www.educative.io/edpresso/fixing-the-invalid-argument-supplied-for-foreach-php-error.
Thanks for supporting! Accepted as solution.
Regards, Woutr
Hi,
How did you fix this issue? I am facing the same issue in the same file. Please can you help