0

I haven't installed any of the modules but when i tried to create a new email template from back-end by loading a default template which is 'Pickup-cancelled' i am facing an issue. The screenshot is shown below enter image description here

And i found an error in the error log , which is

Unable to unserialize value. {"exception":"[object] (InvalidArgumentException(code: 0):

So so far i have tried the solutions which are available on the internet by overriding the jason.php below is the jason.php code which i used to override using a custom class preference

<?php
namespace Serilization\Override\Serialize\Serializer;



class Json extends \Magento\Framework\Serialize\Serializer\Json
{


    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;
    }
    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':
            $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;
}
}

Issue is still exist and it is now locating to my newly created module with the same issue and does anybody know what i am doing wrong here?

1
  • From your error log I can't tell what exactly is causing the issue. I'd be checking the XML files, it might be a tag malformed. Some syntax error. – medina May 8 '20 at 11:01

Your Answer

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

Browse other questions tagged or ask your own question.