cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to serialize value Magento 2.2.1

Unable to serialize value Magento 2.2.1

Hi
I have upgraded website from 2.1.6 to 2.2.1 and facing Unable to serialize value error in frontend and backend.

 

{"0":"Unable to serialize value.","1":"#0 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Translate.php(494): Magento\\Framework\\Serialize\\Serializer\\Json->serialize(Array)\n#1 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Translate.php(190): Magento\\Framework\\Translate->_saveCache()\n#2 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/App\/Area.php(244): Magento\\Framework\\Translate->loadData(NULL, false)\n#3 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/App\/Area.php(215): Magento\\Framework\\App\\Area->_initTranslate()\n#4 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/App\/Area.php(142): Magento\\Framework\\App\\Area->_loadPart('translate')\n#5 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/View\/DesignLoader.php(55): Magento\\Framework\\App\\Area->load('translate')\n#6 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/App\/Action\/Plugin\/Design.php(48): Magento\\Framework\\View\\DesignLoader->load()\n#7 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Interception\/Interceptor.php(121): Magento\\Framework\\App\\Action\\Plugin\\Design->beforeDispatch(Object(Magento\\Cms\\Controller\\Index\\Index\\Interceptor), Object(Magento\\Framework\\App\\Request\\Http))\n#8 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Cms\\Controller\\Index\\Index\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#9 \/var\/www\/vhosts\/demo.com\/eiselec\/generated\/code\/Magento\/Cms\/Controller\/Index\/Index\/Interceptor.php(39): Magento\\Cms\\Controller\\Index\\Index\\Interceptor->___callPlugins('dispatch', Array, Array)\n#10 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/App\/FrontController.php(55): Magento\\Cms\\Controller\\Index\\Index\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#11 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Framework\\App\\FrontController->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#12 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Framework\\App\\FrontController\\Interceptor->___callParent('dispatch', Array)\n#13 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/module-store\/App\/FrontController\/Plugin\/RequestPreprocessor.php(94): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#14 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\\Store\\App\\FrontController\\Plugin\\RequestPreprocessor->aroundDispatch(Object(Magento\\Framework\\App\\FrontController\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\n#15 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/module-page-cache\/Model\/App\/FrontController\/BuiltinPlugin.php(73): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#16 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\\PageCache\\Model\\App\\FrontController\\BuiltinPlugin->aroundDispatch(Object(Magento\\Framework\\App\\FrontController\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\n#17 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#18 \/var\/www\/vhosts\/demo.com\/eiselec\/generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php(26): Magento\\Framework\\App\\FrontController\\Interceptor->___callPlugins('dispatch', Array, NULL)\n#19 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/App\/Http.php(135): Magento\\Framework\\App\\FrontController\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#20 \/var\/www\/vhosts\/demo.com\/eiselec\/vendor\/magento\/framework\/App\/Bootstrap.php(256): Magento\\Framework\\App\\Http->launch()\n#21 \/var\/www\/vhosts\/demo.com\/eiselec\/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#22 {main}","url":"\/","script_name":"\/index.php"}

Please help me to resolve this issue.

 

Thanks

---
If you've found one of my answers useful, please give"Kudos" or "Accept as Solution"
7 REPLIES

Re: Unable to serialize value Magento 2.2.1

Hi @Meetanshi,

 

When you get this error?

Are you using configurable products?

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Unable to serialize value Magento 2.2.1

@Damian Culotta,

I am facing this when i try to open frontend or backend after upgrade.

---
If you've found one of my answers useful, please give"Kudos" or "Accept as Solution"

Re: Unable to serialize value Magento 2.2.1

I have the same issue after upgrading magento from 2.1.7 to 2.2.1.

{"0":"Unable to serialize value.","1":"#0 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/Translate.php(494): Magento\\Framework\\Serialize\\Serializer\\Json->serialize(Array)\n#1 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/Translate.php(190): Magento\\Framework\\Translate->_saveCache()\n#2 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/App\/Area.php(244): Magento\\Framework\\Translate->loadData(NULL, false)\n#3 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/App\/Area.php(215): Magento\\Framework\\App\\Area->_initTranslate()\n#4 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/App\/Area.php(142): Magento\\Framework\\App\\Area->_loadPart('translate')\n#5 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/View\/DesignLoader.php(55): Magento\\Framework\\App\\Area->load('translate')\n#6 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/App\/Action\/Plugin\/Design.php(48): Magento\\Framework\\View\\DesignLoader->load()\n#7 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/Interception\/Interceptor.php(121): Magento\\Framework\\App\\Action\\Plugin\\Design->beforeDispatch(Object(Magento\\Backend\\Controller\\Adminhtml\\Index\\Index\\Interceptor), Object(Magento\\Framework\\App\\Request\\Http))\n#8 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Backend\\Controller\\Adminhtml\\Index\\Index\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#9 \/usr\/www\/users\/whirln\/magento-expert\/generated\/code\/Magento\/Backend\/Controller\/Adminhtml\/Index\/Index\/Interceptor.php(39): Magento\\Backend\\Controller\\Adminhtml\\Index\\Index\\Interceptor->___callPlugins('dispatch', Array, Array)\n#10 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/App\/FrontController.php(55): Magento\\Backend\\Controller\\Adminhtml\\Index\\Index\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#11 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Framework\\App\\FrontController->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#12 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Framework\\App\\FrontController\\Interceptor->___callParent('dispatch', Array)\n#13 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#14 \/usr\/www\/users\/whirln\/magento-expert\/generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php(26): Magento\\Framework\\App\\FrontController\\Interceptor->___callPlugins('dispatch', Array, Array)\n#15 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/App\/Http.php(135): Magento\\Framework\\App\\FrontController\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#16 \/usr\/www\/users\/whirln\/magento-expert\/vendor\/magento\/framework\/App\/Bootstrap.php(256): Magento\\Framework\\App\\Http->launch()\n#17 \/usr\/www\/users\/whirln\/magento-expert\/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#18 {main}","url":"\/adminexpert\/","script_name":"\/index.php"}

Can someone help us with this issue?

Re: Unable to serialize value Magento 2.2.1

In Magento 2.2.* version, In code format with Serialize have some changes.

So suggestion is that you need to deactivate all of your custom module first and check again.

if its works then you need to check enable one by one module to find out actual issue.

 

For Magento 2.2 release, you can check some of the serialize function have made changes.

 

The class \Magento\Eav\Model\Entity\Attribute\Backend\Serialized has been marked as deprecated, Magento\Eav\Model\Entity\Attribute\Backend\JsonEncoded can be used instead.

 

Most of the place replace serialize with json format to gain security in site.

Also check release note for changes in Magento 2.2,Write an upgrade script to update data stored by the extension in the core_config_data table from se...

 

 

If Issue Solved, Click Kudos/Accept As solutions.

Re: Unable to serialize value Magento 2.2.1

I have disabled all external/custom modules, updated the DB and cleared all caches. However, the issue is still there.

I know that the format has changed from PHP to JSON, but why aren't the entries converted? In the report, all errors refer to core files. I don't know how to continue now. There is a guide (http://devdocs.magento.com/guides/v2.2/ext-best-practices/tutorials/serialized-to-json-data-upgrade....), but I don't know how I can use it in my case.

The issue refer to this point in the /vendor/magento/framework/Translate.php:

protected function _saveCache()
    {
        $this->_cache->save($this->getSerializer()->serialize($this->getData()), $this->getCacheId(true), [], false);
        return $this;
    }

    /**
     * Get serializer
     *
     * @return \Magento\Framework\Serialize\SerializerInterface
     * @deprecated 100.2.0
     */
    private function getSerializer()
    {
        if ($this->serializer === null) {
            $this->serializer = \Magento\Framework\App\ObjectManager::getInstance()
                ->get(Serialize\SerializerInterface::class);
        }
        return $this->serializer;
    }

Is it related to the cache? I flushed the magento cache and deleted the folders var/cache/* var/page_cache/* var/generation/* and generated/code/*

Did I forgot something?

 

Re: Unable to serialize value Magento 2.2.1

Does somebody has any idea? What could it be?

Re: Unable to serialize value Magento 2.2.1

To Solve this error ,you have to modify StoreManager.php

(/vendor/magento/module-store/Model/StoreManager.php)

If $storeId is not defined: It retrive data from COOKIE first, otherwise return the default store code. Arround line 154 replace with the below patch:

if (!isset($storeId) || '' === $storeId || $storeId === true) {
if (null === $this->currentStoreId) {
\Magento\Framework\Profiler::start('store.resolve');
$this->currentStoreId = $this->storeResolver->getCurrentStoreId();
\Magento\Framework\Profiler::stop('store.resolve');
}
$storeId = $this->currentStoreId;
}


TO

if(!$storeId){
if(isset($_COOKIE['store']) && $_COOKIE['store'] !== ''){
$storeId = $_COOKIE['store'];
} else {
$storeId = $this->getDefaultStoreView()->getCode();
} 
}