Magento – Magento 2.2.2, Unable to unserialize value, magento_umask and edting Json.php did not help

jsonmagento2.2.2unserialize

After upgrade I'm getting below error in my local :

Exception #0 (InvalidArgumentException): Unable to unserialize value.

#0 myPath/vendor/magento/module-theme/Controller/Result/MessagePlugin.php(157): Magento\Framework\Serialize\Serializer\Json->unserialize('[{\\"type\\":\\"su...')

Tried solutions in below link but none of them helped 🙁

some solutions here

Best Answer

You can try by adding a line in function unserialize of class Magento\Framework\Serialize\Serializer\Json.

This does happen when magento send some invalid string to parse or add string with multiple slashes to the string.

Even you can check exact error from this json_last_error() method.

So for now add stripslashes at the very first line of method body.

so your function should look like this:

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