0

Getting below issue at checkout step after upgrade of magento to 2.3.1 from 2.1.8.

1 exception(s):
Exception #0 (InvalidArgumentException): Unable to serialize value.

Exception #0 (InvalidArgumentException): Unable to serialize value.
<pre>#1 Magento\Checkout\Block\Onepage->getSerializedCheckoutConfig() called at [vendor/magento/module-checkout/view/frontend/templates/onepage.phtml:26]
#2 include('/var/www/project...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:59]
#3 Magento\Framework\View\TemplateEngine\Php->render(&Magento\Checkout\Block\Onepage\Interceptor#000000001d8c0f290000000035fe6de3#, '/var/www/project...', array()) called at [vendor/magento/framework/View/Element/Template.php:271]
#4 Magento\Framework\View\Element\Template->fetchView('/var/www/project...') called at [vendor/magento/framework/View/Element/Template.php:301]
#5 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:668]
#6 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:557]
#7 Magento\Framework\View\Layout->_renderBlock('checkout.root') called at [vendor/magento/framework/View/Layout.php:533]
#8 Magento\Framework\View\Layout->renderNonCachedElement('checkout.root') called at [vendor/magento/framework/View/Layout.php:488]
#9 Magento\Framework\View\Layout->renderElement('checkout.root', false) called at [vendor/magento/framework/View/Layout.php:585]
#10 Magento\Framework\View\Layout->_renderContainer('content', false) called at [vendor/magento/framework/View/Layout.php:535]
#11 Magento\Framework\View\Layout->renderNonCachedElement('content') called at [vendor/magento/framework/View/Layout.php:488]
#12 Magento\Framework\View\Layout->renderElement('content', false) called at [vendor/magento/framework/View/Layout.php:585]
#13 Magento\Framework\View\Layout->_renderContainer('main', false) called at [vendor/magento/framework/View/Layout.php:535]
#14 Magento\Framework\View\Layout->renderNonCachedElement('main') called at [vendor/magento/framework/View/Layout.php:488]

Please let me know if someone faced this before.

1

Magento replaced the serialization by Json in 2.2.2 and later. So it may requires to updates all the database values that were previously saved by serialization.

To patch it and get everything working you try the following patch:

File: /vendor/magento/framework/Serialize/Serializer/Json.php

Find:

public function unserialize($string)
{
    $result = json_decode($string, true);
    if (json_last_error() !== JSON_ERROR_NONE) {
        throw new \InvalidArgumentException('Unable to unserialize value.');
    }
    return $result;
}

replace by:

public function unserialize($string)
{
    $result = json_decode($string, true);
    if (json_last_error() !== JSON_ERROR_NONE) {
        if(false !== @unserialize($string)){
            return unserialize($string);
        }
        throw new \InvalidArgumentException('Unable to unserialize value.');
    }
    return $result;
}
  • Still facing same issue after unserialize replacing method. – groy Jun 18 at 17:42
  • any other suggestion? – groy Jun 21 at 10:06
  • Ok seems like it causing issue while serializing data from checkout config. Could you please look into the method Magento\Checkout\Block\Onepage->getSerializedCheckoutConfig() give a try and replace "$this->serializer->serialize($this->getCheckoutConfig())" to json_encode($this->serializer->serialize($this->getCheckoutConfig())); If it works change json encoding block in the Magento appropriate way. – MageLearner Jun 21 at 12:21
  • I have just replace core_config_data table with magento 2.1.8's , now it is working. TY. – groy Jun 21 at 13:58
0

I'm facing the same issue on the checkout page while upgrading from 2.2.4 to 2.3.1, and I replace core_config_data table with magento 2.2.4 , now it is working perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.