Magento 2.2: Unable to unserialize value?












14















Running into issues on a site running Magento 2.2.0-rc3.0/PHP 7.0.23



The following issue occurs with all 3rd party extensions either enabled or disabled.



When adding an item to comparison from category or product page or submitting a review from product page we get the following error in the browser:



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

Exception #0 (InvalidArgumentException): Unable to unserialize value.
#0 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(157): MagentoFrameworkSerializeSerializerJson->unserialize('[{\"type\":\"su...')
#1 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(135): MagentoThemeControllerResultMessagePlugin->getCookiesMessages()
#2 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(84): MagentoThemeControllerResultMessagePlugin->getMessages()
#3 /home/___/public_html/lib/internal/Magento/Framework/Interception/Interceptor.php(146): MagentoThemeControllerResultMessagePlugin->afterRenderResult(Object(MagentoFrameworkViewResultPageInterceptor), Object(MagentoFrameworkViewResultPageInterceptor), Object(MagentoFrameworkAppResponseHttpInterceptor))
#4 /home/___/public_html/lib/internal/Magento/Framework/Interception/Interceptor.php(153): MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppResponseHttpInterceptor))
#5 /home/___/public_html/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(26): MagentoFrameworkViewResultPageInterceptor->___callPlugins('renderResult', Array, Array)
#6 /home/___/public_html/lib/internal/Magento/Framework/App/Http.php(139): MagentoFrameworkViewResultPageInterceptor->renderResult(Object(MagentoFrameworkAppResponseHttpInterceptor))
#7 /home/___/public_html/lib/internal/Magento/Framework/App/Bootstrap.php(256): MagentoFrameworkAppHttp->launch()
#8 /home/___/public_html/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))
#9 {main}


The error does not go away unless you clear cookies, in particular, the mage-messages cookie.
enter image description here



Any assistance in troubleshooting these errors is appreciated.










share|improve this question

























  • Isn't that a core bug? is there a GitHub issue for this?

    – Alex
    Sep 5 '18 at 20:31
















14















Running into issues on a site running Magento 2.2.0-rc3.0/PHP 7.0.23



The following issue occurs with all 3rd party extensions either enabled or disabled.



When adding an item to comparison from category or product page or submitting a review from product page we get the following error in the browser:



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

Exception #0 (InvalidArgumentException): Unable to unserialize value.
#0 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(157): MagentoFrameworkSerializeSerializerJson->unserialize('[{\"type\":\"su...')
#1 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(135): MagentoThemeControllerResultMessagePlugin->getCookiesMessages()
#2 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(84): MagentoThemeControllerResultMessagePlugin->getMessages()
#3 /home/___/public_html/lib/internal/Magento/Framework/Interception/Interceptor.php(146): MagentoThemeControllerResultMessagePlugin->afterRenderResult(Object(MagentoFrameworkViewResultPageInterceptor), Object(MagentoFrameworkViewResultPageInterceptor), Object(MagentoFrameworkAppResponseHttpInterceptor))
#4 /home/___/public_html/lib/internal/Magento/Framework/Interception/Interceptor.php(153): MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppResponseHttpInterceptor))
#5 /home/___/public_html/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(26): MagentoFrameworkViewResultPageInterceptor->___callPlugins('renderResult', Array, Array)
#6 /home/___/public_html/lib/internal/Magento/Framework/App/Http.php(139): MagentoFrameworkViewResultPageInterceptor->renderResult(Object(MagentoFrameworkAppResponseHttpInterceptor))
#7 /home/___/public_html/lib/internal/Magento/Framework/App/Bootstrap.php(256): MagentoFrameworkAppHttp->launch()
#8 /home/___/public_html/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))
#9 {main}


The error does not go away unless you clear cookies, in particular, the mage-messages cookie.
enter image description here



Any assistance in troubleshooting these errors is appreciated.










share|improve this question

























  • Isn't that a core bug? is there a GitHub issue for this?

    – Alex
    Sep 5 '18 at 20:31














14












14








14


6






Running into issues on a site running Magento 2.2.0-rc3.0/PHP 7.0.23



The following issue occurs with all 3rd party extensions either enabled or disabled.



When adding an item to comparison from category or product page or submitting a review from product page we get the following error in the browser:



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

Exception #0 (InvalidArgumentException): Unable to unserialize value.
#0 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(157): MagentoFrameworkSerializeSerializerJson->unserialize('[{\"type\":\"su...')
#1 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(135): MagentoThemeControllerResultMessagePlugin->getCookiesMessages()
#2 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(84): MagentoThemeControllerResultMessagePlugin->getMessages()
#3 /home/___/public_html/lib/internal/Magento/Framework/Interception/Interceptor.php(146): MagentoThemeControllerResultMessagePlugin->afterRenderResult(Object(MagentoFrameworkViewResultPageInterceptor), Object(MagentoFrameworkViewResultPageInterceptor), Object(MagentoFrameworkAppResponseHttpInterceptor))
#4 /home/___/public_html/lib/internal/Magento/Framework/Interception/Interceptor.php(153): MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppResponseHttpInterceptor))
#5 /home/___/public_html/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(26): MagentoFrameworkViewResultPageInterceptor->___callPlugins('renderResult', Array, Array)
#6 /home/___/public_html/lib/internal/Magento/Framework/App/Http.php(139): MagentoFrameworkViewResultPageInterceptor->renderResult(Object(MagentoFrameworkAppResponseHttpInterceptor))
#7 /home/___/public_html/lib/internal/Magento/Framework/App/Bootstrap.php(256): MagentoFrameworkAppHttp->launch()
#8 /home/___/public_html/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))
#9 {main}


The error does not go away unless you clear cookies, in particular, the mage-messages cookie.
enter image description here



Any assistance in troubleshooting these errors is appreciated.










share|improve this question
















Running into issues on a site running Magento 2.2.0-rc3.0/PHP 7.0.23



The following issue occurs with all 3rd party extensions either enabled or disabled.



When adding an item to comparison from category or product page or submitting a review from product page we get the following error in the browser:



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

Exception #0 (InvalidArgumentException): Unable to unserialize value.
#0 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(157): MagentoFrameworkSerializeSerializerJson->unserialize('[{\"type\":\"su...')
#1 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(135): MagentoThemeControllerResultMessagePlugin->getCookiesMessages()
#2 /home/___/public_html/app/code/Magento/Theme/Controller/Result/MessagePlugin.php(84): MagentoThemeControllerResultMessagePlugin->getMessages()
#3 /home/___/public_html/lib/internal/Magento/Framework/Interception/Interceptor.php(146): MagentoThemeControllerResultMessagePlugin->afterRenderResult(Object(MagentoFrameworkViewResultPageInterceptor), Object(MagentoFrameworkViewResultPageInterceptor), Object(MagentoFrameworkAppResponseHttpInterceptor))
#4 /home/___/public_html/lib/internal/Magento/Framework/Interception/Interceptor.php(153): MagentoFrameworkViewResultPageInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppResponseHttpInterceptor))
#5 /home/___/public_html/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(26): MagentoFrameworkViewResultPageInterceptor->___callPlugins('renderResult', Array, Array)
#6 /home/___/public_html/lib/internal/Magento/Framework/App/Http.php(139): MagentoFrameworkViewResultPageInterceptor->renderResult(Object(MagentoFrameworkAppResponseHttpInterceptor))
#7 /home/___/public_html/lib/internal/Magento/Framework/App/Bootstrap.php(256): MagentoFrameworkAppHttp->launch()
#8 /home/___/public_html/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))
#9 {main}


The error does not go away unless you clear cookies, in particular, the mage-messages cookie.
enter image description here



Any assistance in troubleshooting these errors is appreciated.







magento2 magento2.2-dev unserialize






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 28 '17 at 2:13







Chuck

















asked Sep 20 '17 at 20:18









ChuckChuck

2811212




2811212













  • Isn't that a core bug? is there a GitHub issue for this?

    – Alex
    Sep 5 '18 at 20:31



















  • Isn't that a core bug? is there a GitHub issue for this?

    – Alex
    Sep 5 '18 at 20:31

















Isn't that a core bug? is there a GitHub issue for this?

– Alex
Sep 5 '18 at 20:31





Isn't that a core bug? is there a GitHub issue for this?

– Alex
Sep 5 '18 at 20:31










11 Answers
11






active

oldest

votes


















21














The problem is in /vendor/magento/framework/Serialize/Serializer/Json.php there is a function unserialize($string) which gives you a syntax error if string is serialized (not json but php serialization).



There is a workaround - you can check if string is serialized (vs json-encoded) and then use serialize($string). Change unserialize to:



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;
}


and add function to check if string is serialized:



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;
}


After save fe. category without problem, You can restore class to default and there wont be such problem in future.






share|improve this answer


























  • Its working 100% fine for me. Thanks a lot!

    – mapaladiya
    Nov 9 '17 at 10:03











  • it is not working ... :-(

    – Arfan Mirza
    Dec 10 '17 at 1:30











  • works perfect thanks!

    – Kevin Chavez
    Jan 8 '18 at 19:45











  • Working perfect for me. Thanks

    – Suman Pradhan
    Jan 12 '18 at 6:19











  • Check what happens if the value a:0:{} is passed. Go line by line. What happens if the result of unserialize is passed to a strong typed method that is expecting an array? You might want to change your answer.

    – vitoriodachef
    May 1 '18 at 10:47



















20














I was able to resolve this issue by Flushing my Redis Cache from the CLI



redis-cli flushall


I hope this helps future users.






share|improve this answer



















  • 1





    Nicely done. This should probably be the accepted answer.

    – Shawn Abramson
    May 16 '18 at 15:39











  • It seems to not always be the solution. In my case I do not even use redis (yet)

    – Alex
    Sep 5 '18 at 20:40











  • thanks. i restarted varnish, thinking that would flush it, but this did the trick.

    – ladle3000
    Jan 13 at 23:49



















13














Do not edit core files for solution. Override following way
Just put following line in di.xml inside etc directory



<preference for="MagentoFrameworkSerializeSerializerJson" type="NamespaceModuleNameSerializeSerializerJson" />


And inside NamespaceModuleNameSerializeSerializer Directory: file Json.php



<?php
namespace NamespaceModuleNameSerializeSerializer;



class Json extends MagentoFrameworkSerializeSerializerJson
{


/**
* {@inheritDoc}
* @since 100.2.0
*/
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;
}
}


Works perfectly






share|improve this answer



















  • 2





    The implementation is flawed. What happens if the value a:0:{} is passed to Json:unserialize method? Is it the desired behaviour? What is the point of the result variable in is_serialized method? It's not returned and it doesn't have impact over anything as at method call no variable is passed as second argument.

    – vitoriodachef
    May 1 '18 at 10:51











  • This should be the accepted solution, and is much better than the post above to edit the file directly in vendor. More than likely, you'll have to run the setup upgrade task locally and then again on staging/production, so it'll have to persist environments and vendor/ directory is an artifact created at build time.

    – Mark Shust
    Aug 28 '18 at 13:54











  • @vitoriodachef I'm facing the exact case you have mentioned. Do you have found any solution?

    – Knight017
    Dec 5 '18 at 4:50











  • I have used following function to decide private function isSerialized($value) { return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value); }

    – Knight017
    Dec 20 '18 at 10:50





















3














It turned out to be a permissions issue, where magento was setting permissions for generated files that were restricted on this server.



Solved by creating magento_umask file in the root directory with the appropriate umask for the server.



See http://devdocs.magento.com/guides/v2.2/install-gde/install/post-install-umask.html for additional details.






share|improve this answer
























  • Hello, I am facing the related issue like this. Can you please look in to this .

    – Aditya Shah
    May 14 '18 at 7:07



















1














It's mostly related with Redis cache, so try to flush out this with simple command in your SSH



redis-cli flushall






share|improve this answer































    1














    Sameers' answer above worked for me although i had to use different code in the block.



    public function serialize($data)
    {
    $result = json_encode($data);
    if (false === $result) {
    throw new InvalidArgumentException('Unable to serialize 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;
    }

    /**
    * {@inheritDoc}
    */
    public function unserialize($string)
    {
    if($this->is_serialized($string))
    {
    $result = $this->serialize($string);
    }
    $result = json_decode($string, true);

    return $result;
    }





    share|improve this answer































      1














      After flushing Redis the issue has sorted.
      Thank you Craig for the solution.



      I'm using port 6379 for cache, so I run command :



      redis-cli -p 6379 flushall





      share|improve this answer































        1














        ROOT directory
        1. public_html/vendor/magento/framework/Serialize/Serializer/Json.php



        Download JSON.php https://gist.github.com/manojind/9f18bbecaeb3e2bbfb056a634ade62a2



        2. Just replace below function (unserialize) and add new function OR just download the attached file and replace with default



        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;
        }


        3. Add new function :



        function is_serialized($value, &$result = null)
        {

        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;
        }





        share|improve this answer

































          0














          I was getting the error in a CMS page in front end.



          It was the Magento widget code in the CMS Page Content that was causing problem(which I copied from another source). I deleted the widget code and inserted the same widget using the Insert Widget button in the CMS Page edit screen and it worked.



          The above process formatted the widget code differently and it made the error go away.






          share|improve this answer































            0














            I found out that whole serialized data cannot be fit into a database MySQL table column with TEXT data type.
            I just found the column flag_data value of system_config_snapshot line is trimmed.



            I had to change it to MEDIUMTEXT for this column flag.flag_data.






            share|improve this answer































              0














              I personally found this issue reared it's head running the command:



              php bin/magento setup:upgrade


              After a migration. I found out that I was missing the "crypt" hash key in src/app/etc/env.php:



              <?php
              return [
              'backend' => [
              'frontName' => 'admin'
              ],
              'crypt' => [
              'key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
              ],

              ...


              Ensure this is not empty and preferably matches your projects' other environments!





              share























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "479"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f194010%2fmagento-2-2-unable-to-unserialize-value%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                11 Answers
                11






                active

                oldest

                votes








                11 Answers
                11






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                21














                The problem is in /vendor/magento/framework/Serialize/Serializer/Json.php there is a function unserialize($string) which gives you a syntax error if string is serialized (not json but php serialization).



                There is a workaround - you can check if string is serialized (vs json-encoded) and then use serialize($string). Change unserialize to:



                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;
                }


                and add function to check if string is serialized:



                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;
                }


                After save fe. category without problem, You can restore class to default and there wont be such problem in future.






                share|improve this answer


























                • Its working 100% fine for me. Thanks a lot!

                  – mapaladiya
                  Nov 9 '17 at 10:03











                • it is not working ... :-(

                  – Arfan Mirza
                  Dec 10 '17 at 1:30











                • works perfect thanks!

                  – Kevin Chavez
                  Jan 8 '18 at 19:45











                • Working perfect for me. Thanks

                  – Suman Pradhan
                  Jan 12 '18 at 6:19











                • Check what happens if the value a:0:{} is passed. Go line by line. What happens if the result of unserialize is passed to a strong typed method that is expecting an array? You might want to change your answer.

                  – vitoriodachef
                  May 1 '18 at 10:47
















                21














                The problem is in /vendor/magento/framework/Serialize/Serializer/Json.php there is a function unserialize($string) which gives you a syntax error if string is serialized (not json but php serialization).



                There is a workaround - you can check if string is serialized (vs json-encoded) and then use serialize($string). Change unserialize to:



                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;
                }


                and add function to check if string is serialized:



                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;
                }


                After save fe. category without problem, You can restore class to default and there wont be such problem in future.






                share|improve this answer


























                • Its working 100% fine for me. Thanks a lot!

                  – mapaladiya
                  Nov 9 '17 at 10:03











                • it is not working ... :-(

                  – Arfan Mirza
                  Dec 10 '17 at 1:30











                • works perfect thanks!

                  – Kevin Chavez
                  Jan 8 '18 at 19:45











                • Working perfect for me. Thanks

                  – Suman Pradhan
                  Jan 12 '18 at 6:19











                • Check what happens if the value a:0:{} is passed. Go line by line. What happens if the result of unserialize is passed to a strong typed method that is expecting an array? You might want to change your answer.

                  – vitoriodachef
                  May 1 '18 at 10:47














                21












                21








                21







                The problem is in /vendor/magento/framework/Serialize/Serializer/Json.php there is a function unserialize($string) which gives you a syntax error if string is serialized (not json but php serialization).



                There is a workaround - you can check if string is serialized (vs json-encoded) and then use serialize($string). Change unserialize to:



                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;
                }


                and add function to check if string is serialized:



                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;
                }


                After save fe. category without problem, You can restore class to default and there wont be such problem in future.






                share|improve this answer















                The problem is in /vendor/magento/framework/Serialize/Serializer/Json.php there is a function unserialize($string) which gives you a syntax error if string is serialized (not json but php serialization).



                There is a workaround - you can check if string is serialized (vs json-encoded) and then use serialize($string). Change unserialize to:



                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;
                }


                and add function to check if string is serialized:



                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;
                }


                After save fe. category without problem, You can restore class to default and there wont be such problem in future.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 18 '17 at 0:02









                Felix

                30937




                30937










                answered Oct 22 '17 at 12:58









                EdmundEdmund

                35712




                35712













                • Its working 100% fine for me. Thanks a lot!

                  – mapaladiya
                  Nov 9 '17 at 10:03











                • it is not working ... :-(

                  – Arfan Mirza
                  Dec 10 '17 at 1:30











                • works perfect thanks!

                  – Kevin Chavez
                  Jan 8 '18 at 19:45











                • Working perfect for me. Thanks

                  – Suman Pradhan
                  Jan 12 '18 at 6:19











                • Check what happens if the value a:0:{} is passed. Go line by line. What happens if the result of unserialize is passed to a strong typed method that is expecting an array? You might want to change your answer.

                  – vitoriodachef
                  May 1 '18 at 10:47



















                • Its working 100% fine for me. Thanks a lot!

                  – mapaladiya
                  Nov 9 '17 at 10:03











                • it is not working ... :-(

                  – Arfan Mirza
                  Dec 10 '17 at 1:30











                • works perfect thanks!

                  – Kevin Chavez
                  Jan 8 '18 at 19:45











                • Working perfect for me. Thanks

                  – Suman Pradhan
                  Jan 12 '18 at 6:19











                • Check what happens if the value a:0:{} is passed. Go line by line. What happens if the result of unserialize is passed to a strong typed method that is expecting an array? You might want to change your answer.

                  – vitoriodachef
                  May 1 '18 at 10:47

















                Its working 100% fine for me. Thanks a lot!

                – mapaladiya
                Nov 9 '17 at 10:03





                Its working 100% fine for me. Thanks a lot!

                – mapaladiya
                Nov 9 '17 at 10:03













                it is not working ... :-(

                – Arfan Mirza
                Dec 10 '17 at 1:30





                it is not working ... :-(

                – Arfan Mirza
                Dec 10 '17 at 1:30













                works perfect thanks!

                – Kevin Chavez
                Jan 8 '18 at 19:45





                works perfect thanks!

                – Kevin Chavez
                Jan 8 '18 at 19:45













                Working perfect for me. Thanks

                – Suman Pradhan
                Jan 12 '18 at 6:19





                Working perfect for me. Thanks

                – Suman Pradhan
                Jan 12 '18 at 6:19













                Check what happens if the value a:0:{} is passed. Go line by line. What happens if the result of unserialize is passed to a strong typed method that is expecting an array? You might want to change your answer.

                – vitoriodachef
                May 1 '18 at 10:47





                Check what happens if the value a:0:{} is passed. Go line by line. What happens if the result of unserialize is passed to a strong typed method that is expecting an array? You might want to change your answer.

                – vitoriodachef
                May 1 '18 at 10:47













                20














                I was able to resolve this issue by Flushing my Redis Cache from the CLI



                redis-cli flushall


                I hope this helps future users.






                share|improve this answer



















                • 1





                  Nicely done. This should probably be the accepted answer.

                  – Shawn Abramson
                  May 16 '18 at 15:39











                • It seems to not always be the solution. In my case I do not even use redis (yet)

                  – Alex
                  Sep 5 '18 at 20:40











                • thanks. i restarted varnish, thinking that would flush it, but this did the trick.

                  – ladle3000
                  Jan 13 at 23:49
















                20














                I was able to resolve this issue by Flushing my Redis Cache from the CLI



                redis-cli flushall


                I hope this helps future users.






                share|improve this answer



















                • 1





                  Nicely done. This should probably be the accepted answer.

                  – Shawn Abramson
                  May 16 '18 at 15:39











                • It seems to not always be the solution. In my case I do not even use redis (yet)

                  – Alex
                  Sep 5 '18 at 20:40











                • thanks. i restarted varnish, thinking that would flush it, but this did the trick.

                  – ladle3000
                  Jan 13 at 23:49














                20












                20








                20







                I was able to resolve this issue by Flushing my Redis Cache from the CLI



                redis-cli flushall


                I hope this helps future users.






                share|improve this answer













                I was able to resolve this issue by Flushing my Redis Cache from the CLI



                redis-cli flushall


                I hope this helps future users.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 11 '17 at 14:02









                CraigCraig

                7371519




                7371519








                • 1





                  Nicely done. This should probably be the accepted answer.

                  – Shawn Abramson
                  May 16 '18 at 15:39











                • It seems to not always be the solution. In my case I do not even use redis (yet)

                  – Alex
                  Sep 5 '18 at 20:40











                • thanks. i restarted varnish, thinking that would flush it, but this did the trick.

                  – ladle3000
                  Jan 13 at 23:49














                • 1





                  Nicely done. This should probably be the accepted answer.

                  – Shawn Abramson
                  May 16 '18 at 15:39











                • It seems to not always be the solution. In my case I do not even use redis (yet)

                  – Alex
                  Sep 5 '18 at 20:40











                • thanks. i restarted varnish, thinking that would flush it, but this did the trick.

                  – ladle3000
                  Jan 13 at 23:49








                1




                1





                Nicely done. This should probably be the accepted answer.

                – Shawn Abramson
                May 16 '18 at 15:39





                Nicely done. This should probably be the accepted answer.

                – Shawn Abramson
                May 16 '18 at 15:39













                It seems to not always be the solution. In my case I do not even use redis (yet)

                – Alex
                Sep 5 '18 at 20:40





                It seems to not always be the solution. In my case I do not even use redis (yet)

                – Alex
                Sep 5 '18 at 20:40













                thanks. i restarted varnish, thinking that would flush it, but this did the trick.

                – ladle3000
                Jan 13 at 23:49





                thanks. i restarted varnish, thinking that would flush it, but this did the trick.

                – ladle3000
                Jan 13 at 23:49











                13














                Do not edit core files for solution. Override following way
                Just put following line in di.xml inside etc directory



                <preference for="MagentoFrameworkSerializeSerializerJson" type="NamespaceModuleNameSerializeSerializerJson" />


                And inside NamespaceModuleNameSerializeSerializer Directory: file Json.php



                <?php
                namespace NamespaceModuleNameSerializeSerializer;



                class Json extends MagentoFrameworkSerializeSerializerJson
                {


                /**
                * {@inheritDoc}
                * @since 100.2.0
                */
                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;
                }
                }


                Works perfectly






                share|improve this answer



















                • 2





                  The implementation is flawed. What happens if the value a:0:{} is passed to Json:unserialize method? Is it the desired behaviour? What is the point of the result variable in is_serialized method? It's not returned and it doesn't have impact over anything as at method call no variable is passed as second argument.

                  – vitoriodachef
                  May 1 '18 at 10:51











                • This should be the accepted solution, and is much better than the post above to edit the file directly in vendor. More than likely, you'll have to run the setup upgrade task locally and then again on staging/production, so it'll have to persist environments and vendor/ directory is an artifact created at build time.

                  – Mark Shust
                  Aug 28 '18 at 13:54











                • @vitoriodachef I'm facing the exact case you have mentioned. Do you have found any solution?

                  – Knight017
                  Dec 5 '18 at 4:50











                • I have used following function to decide private function isSerialized($value) { return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value); }

                  – Knight017
                  Dec 20 '18 at 10:50


















                13














                Do not edit core files for solution. Override following way
                Just put following line in di.xml inside etc directory



                <preference for="MagentoFrameworkSerializeSerializerJson" type="NamespaceModuleNameSerializeSerializerJson" />


                And inside NamespaceModuleNameSerializeSerializer Directory: file Json.php



                <?php
                namespace NamespaceModuleNameSerializeSerializer;



                class Json extends MagentoFrameworkSerializeSerializerJson
                {


                /**
                * {@inheritDoc}
                * @since 100.2.0
                */
                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;
                }
                }


                Works perfectly






                share|improve this answer



















                • 2





                  The implementation is flawed. What happens if the value a:0:{} is passed to Json:unserialize method? Is it the desired behaviour? What is the point of the result variable in is_serialized method? It's not returned and it doesn't have impact over anything as at method call no variable is passed as second argument.

                  – vitoriodachef
                  May 1 '18 at 10:51











                • This should be the accepted solution, and is much better than the post above to edit the file directly in vendor. More than likely, you'll have to run the setup upgrade task locally and then again on staging/production, so it'll have to persist environments and vendor/ directory is an artifact created at build time.

                  – Mark Shust
                  Aug 28 '18 at 13:54











                • @vitoriodachef I'm facing the exact case you have mentioned. Do you have found any solution?

                  – Knight017
                  Dec 5 '18 at 4:50











                • I have used following function to decide private function isSerialized($value) { return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value); }

                  – Knight017
                  Dec 20 '18 at 10:50
















                13












                13








                13







                Do not edit core files for solution. Override following way
                Just put following line in di.xml inside etc directory



                <preference for="MagentoFrameworkSerializeSerializerJson" type="NamespaceModuleNameSerializeSerializerJson" />


                And inside NamespaceModuleNameSerializeSerializer Directory: file Json.php



                <?php
                namespace NamespaceModuleNameSerializeSerializer;



                class Json extends MagentoFrameworkSerializeSerializerJson
                {


                /**
                * {@inheritDoc}
                * @since 100.2.0
                */
                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;
                }
                }


                Works perfectly






                share|improve this answer













                Do not edit core files for solution. Override following way
                Just put following line in di.xml inside etc directory



                <preference for="MagentoFrameworkSerializeSerializerJson" type="NamespaceModuleNameSerializeSerializerJson" />


                And inside NamespaceModuleNameSerializeSerializer Directory: file Json.php



                <?php
                namespace NamespaceModuleNameSerializeSerializer;



                class Json extends MagentoFrameworkSerializeSerializerJson
                {


                /**
                * {@inheritDoc}
                * @since 100.2.0
                */
                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;
                }
                }


                Works perfectly







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 21 '18 at 5:54









                Sameer BhayaniSameer Bhayani

                708417




                708417








                • 2





                  The implementation is flawed. What happens if the value a:0:{} is passed to Json:unserialize method? Is it the desired behaviour? What is the point of the result variable in is_serialized method? It's not returned and it doesn't have impact over anything as at method call no variable is passed as second argument.

                  – vitoriodachef
                  May 1 '18 at 10:51











                • This should be the accepted solution, and is much better than the post above to edit the file directly in vendor. More than likely, you'll have to run the setup upgrade task locally and then again on staging/production, so it'll have to persist environments and vendor/ directory is an artifact created at build time.

                  – Mark Shust
                  Aug 28 '18 at 13:54











                • @vitoriodachef I'm facing the exact case you have mentioned. Do you have found any solution?

                  – Knight017
                  Dec 5 '18 at 4:50











                • I have used following function to decide private function isSerialized($value) { return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value); }

                  – Knight017
                  Dec 20 '18 at 10:50
















                • 2





                  The implementation is flawed. What happens if the value a:0:{} is passed to Json:unserialize method? Is it the desired behaviour? What is the point of the result variable in is_serialized method? It's not returned and it doesn't have impact over anything as at method call no variable is passed as second argument.

                  – vitoriodachef
                  May 1 '18 at 10:51











                • This should be the accepted solution, and is much better than the post above to edit the file directly in vendor. More than likely, you'll have to run the setup upgrade task locally and then again on staging/production, so it'll have to persist environments and vendor/ directory is an artifact created at build time.

                  – Mark Shust
                  Aug 28 '18 at 13:54











                • @vitoriodachef I'm facing the exact case you have mentioned. Do you have found any solution?

                  – Knight017
                  Dec 5 '18 at 4:50











                • I have used following function to decide private function isSerialized($value) { return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value); }

                  – Knight017
                  Dec 20 '18 at 10:50










                2




                2





                The implementation is flawed. What happens if the value a:0:{} is passed to Json:unserialize method? Is it the desired behaviour? What is the point of the result variable in is_serialized method? It's not returned and it doesn't have impact over anything as at method call no variable is passed as second argument.

                – vitoriodachef
                May 1 '18 at 10:51





                The implementation is flawed. What happens if the value a:0:{} is passed to Json:unserialize method? Is it the desired behaviour? What is the point of the result variable in is_serialized method? It's not returned and it doesn't have impact over anything as at method call no variable is passed as second argument.

                – vitoriodachef
                May 1 '18 at 10:51













                This should be the accepted solution, and is much better than the post above to edit the file directly in vendor. More than likely, you'll have to run the setup upgrade task locally and then again on staging/production, so it'll have to persist environments and vendor/ directory is an artifact created at build time.

                – Mark Shust
                Aug 28 '18 at 13:54





                This should be the accepted solution, and is much better than the post above to edit the file directly in vendor. More than likely, you'll have to run the setup upgrade task locally and then again on staging/production, so it'll have to persist environments and vendor/ directory is an artifact created at build time.

                – Mark Shust
                Aug 28 '18 at 13:54













                @vitoriodachef I'm facing the exact case you have mentioned. Do you have found any solution?

                – Knight017
                Dec 5 '18 at 4:50





                @vitoriodachef I'm facing the exact case you have mentioned. Do you have found any solution?

                – Knight017
                Dec 5 '18 at 4:50













                I have used following function to decide private function isSerialized($value) { return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value); }

                – Knight017
                Dec 20 '18 at 10:50







                I have used following function to decide private function isSerialized($value) { return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value); }

                – Knight017
                Dec 20 '18 at 10:50













                3














                It turned out to be a permissions issue, where magento was setting permissions for generated files that were restricted on this server.



                Solved by creating magento_umask file in the root directory with the appropriate umask for the server.



                See http://devdocs.magento.com/guides/v2.2/install-gde/install/post-install-umask.html for additional details.






                share|improve this answer
























                • Hello, I am facing the related issue like this. Can you please look in to this .

                  – Aditya Shah
                  May 14 '18 at 7:07
















                3














                It turned out to be a permissions issue, where magento was setting permissions for generated files that were restricted on this server.



                Solved by creating magento_umask file in the root directory with the appropriate umask for the server.



                See http://devdocs.magento.com/guides/v2.2/install-gde/install/post-install-umask.html for additional details.






                share|improve this answer
























                • Hello, I am facing the related issue like this. Can you please look in to this .

                  – Aditya Shah
                  May 14 '18 at 7:07














                3












                3








                3







                It turned out to be a permissions issue, where magento was setting permissions for generated files that were restricted on this server.



                Solved by creating magento_umask file in the root directory with the appropriate umask for the server.



                See http://devdocs.magento.com/guides/v2.2/install-gde/install/post-install-umask.html for additional details.






                share|improve this answer













                It turned out to be a permissions issue, where magento was setting permissions for generated files that were restricted on this server.



                Solved by creating magento_umask file in the root directory with the appropriate umask for the server.



                See http://devdocs.magento.com/guides/v2.2/install-gde/install/post-install-umask.html for additional details.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 26 '17 at 17:58









                ChuckChuck

                2811212




                2811212













                • Hello, I am facing the related issue like this. Can you please look in to this .

                  – Aditya Shah
                  May 14 '18 at 7:07



















                • Hello, I am facing the related issue like this. Can you please look in to this .

                  – Aditya Shah
                  May 14 '18 at 7:07

















                Hello, I am facing the related issue like this. Can you please look in to this .

                – Aditya Shah
                May 14 '18 at 7:07





                Hello, I am facing the related issue like this. Can you please look in to this .

                – Aditya Shah
                May 14 '18 at 7:07











                1














                It's mostly related with Redis cache, so try to flush out this with simple command in your SSH



                redis-cli flushall






                share|improve this answer




























                  1














                  It's mostly related with Redis cache, so try to flush out this with simple command in your SSH



                  redis-cli flushall






                  share|improve this answer


























                    1












                    1








                    1







                    It's mostly related with Redis cache, so try to flush out this with simple command in your SSH



                    redis-cli flushall






                    share|improve this answer













                    It's mostly related with Redis cache, so try to flush out this with simple command in your SSH



                    redis-cli flushall







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 20 '18 at 6:36









                    Tahir Iqbal NajamTahir Iqbal Najam

                    113




                    113























                        1














                        Sameers' answer above worked for me although i had to use different code in the block.



                        public function serialize($data)
                        {
                        $result = json_encode($data);
                        if (false === $result) {
                        throw new InvalidArgumentException('Unable to serialize 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;
                        }

                        /**
                        * {@inheritDoc}
                        */
                        public function unserialize($string)
                        {
                        if($this->is_serialized($string))
                        {
                        $result = $this->serialize($string);
                        }
                        $result = json_decode($string, true);

                        return $result;
                        }





                        share|improve this answer




























                          1














                          Sameers' answer above worked for me although i had to use different code in the block.



                          public function serialize($data)
                          {
                          $result = json_encode($data);
                          if (false === $result) {
                          throw new InvalidArgumentException('Unable to serialize 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;
                          }

                          /**
                          * {@inheritDoc}
                          */
                          public function unserialize($string)
                          {
                          if($this->is_serialized($string))
                          {
                          $result = $this->serialize($string);
                          }
                          $result = json_decode($string, true);

                          return $result;
                          }





                          share|improve this answer


























                            1












                            1








                            1







                            Sameers' answer above worked for me although i had to use different code in the block.



                            public function serialize($data)
                            {
                            $result = json_encode($data);
                            if (false === $result) {
                            throw new InvalidArgumentException('Unable to serialize 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;
                            }

                            /**
                            * {@inheritDoc}
                            */
                            public function unserialize($string)
                            {
                            if($this->is_serialized($string))
                            {
                            $result = $this->serialize($string);
                            }
                            $result = json_decode($string, true);

                            return $result;
                            }





                            share|improve this answer













                            Sameers' answer above worked for me although i had to use different code in the block.



                            public function serialize($data)
                            {
                            $result = json_encode($data);
                            if (false === $result) {
                            throw new InvalidArgumentException('Unable to serialize 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;
                            }

                            /**
                            * {@inheritDoc}
                            */
                            public function unserialize($string)
                            {
                            if($this->is_serialized($string))
                            {
                            $result = $this->serialize($string);
                            }
                            $result = json_decode($string, true);

                            return $result;
                            }






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 13 '18 at 9:56









                            Adam JacksonAdam Jackson

                            111




                            111























                                1














                                After flushing Redis the issue has sorted.
                                Thank you Craig for the solution.



                                I'm using port 6379 for cache, so I run command :



                                redis-cli -p 6379 flushall





                                share|improve this answer




























                                  1














                                  After flushing Redis the issue has sorted.
                                  Thank you Craig for the solution.



                                  I'm using port 6379 for cache, so I run command :



                                  redis-cli -p 6379 flushall





                                  share|improve this answer


























                                    1












                                    1








                                    1







                                    After flushing Redis the issue has sorted.
                                    Thank you Craig for the solution.



                                    I'm using port 6379 for cache, so I run command :



                                    redis-cli -p 6379 flushall





                                    share|improve this answer













                                    After flushing Redis the issue has sorted.
                                    Thank you Craig for the solution.



                                    I'm using port 6379 for cache, so I run command :



                                    redis-cli -p 6379 flushall






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered May 11 '18 at 19:23









                                    Praveen P. RokadePraveen P. Rokade

                                    111




                                    111























                                        1














                                        ROOT directory
                                        1. public_html/vendor/magento/framework/Serialize/Serializer/Json.php



                                        Download JSON.php https://gist.github.com/manojind/9f18bbecaeb3e2bbfb056a634ade62a2



                                        2. Just replace below function (unserialize) and add new function OR just download the attached file and replace with default



                                        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;
                                        }


                                        3. Add new function :



                                        function is_serialized($value, &$result = null)
                                        {

                                        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;
                                        }





                                        share|improve this answer






























                                          1














                                          ROOT directory
                                          1. public_html/vendor/magento/framework/Serialize/Serializer/Json.php



                                          Download JSON.php https://gist.github.com/manojind/9f18bbecaeb3e2bbfb056a634ade62a2



                                          2. Just replace below function (unserialize) and add new function OR just download the attached file and replace with default



                                          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;
                                          }


                                          3. Add new function :



                                          function is_serialized($value, &$result = null)
                                          {

                                          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;
                                          }





                                          share|improve this answer




























                                            1












                                            1








                                            1







                                            ROOT directory
                                            1. public_html/vendor/magento/framework/Serialize/Serializer/Json.php



                                            Download JSON.php https://gist.github.com/manojind/9f18bbecaeb3e2bbfb056a634ade62a2



                                            2. Just replace below function (unserialize) and add new function OR just download the attached file and replace with default



                                            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;
                                            }


                                            3. Add new function :



                                            function is_serialized($value, &$result = null)
                                            {

                                            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;
                                            }





                                            share|improve this answer















                                            ROOT directory
                                            1. public_html/vendor/magento/framework/Serialize/Serializer/Json.php



                                            Download JSON.php https://gist.github.com/manojind/9f18bbecaeb3e2bbfb056a634ade62a2



                                            2. Just replace below function (unserialize) and add new function OR just download the attached file and replace with default



                                            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;
                                            }


                                            3. Add new function :



                                            function is_serialized($value, &$result = null)
                                            {

                                            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;
                                            }






                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Sep 3 '18 at 9:50









                                            Rama Chandran M

                                            2,71181430




                                            2,71181430










                                            answered Sep 3 '18 at 9:22









                                            mnojindmnojind

                                            213




                                            213























                                                0














                                                I was getting the error in a CMS page in front end.



                                                It was the Magento widget code in the CMS Page Content that was causing problem(which I copied from another source). I deleted the widget code and inserted the same widget using the Insert Widget button in the CMS Page edit screen and it worked.



                                                The above process formatted the widget code differently and it made the error go away.






                                                share|improve this answer




























                                                  0














                                                  I was getting the error in a CMS page in front end.



                                                  It was the Magento widget code in the CMS Page Content that was causing problem(which I copied from another source). I deleted the widget code and inserted the same widget using the Insert Widget button in the CMS Page edit screen and it worked.



                                                  The above process formatted the widget code differently and it made the error go away.






                                                  share|improve this answer


























                                                    0












                                                    0








                                                    0







                                                    I was getting the error in a CMS page in front end.



                                                    It was the Magento widget code in the CMS Page Content that was causing problem(which I copied from another source). I deleted the widget code and inserted the same widget using the Insert Widget button in the CMS Page edit screen and it worked.



                                                    The above process formatted the widget code differently and it made the error go away.






                                                    share|improve this answer













                                                    I was getting the error in a CMS page in front end.



                                                    It was the Magento widget code in the CMS Page Content that was causing problem(which I copied from another source). I deleted the widget code and inserted the same widget using the Insert Widget button in the CMS Page edit screen and it worked.



                                                    The above process formatted the widget code differently and it made the error go away.







                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Mar 7 '18 at 11:18









                                                    BinodBinod

                                                    247311




                                                    247311























                                                        0














                                                        I found out that whole serialized data cannot be fit into a database MySQL table column with TEXT data type.
                                                        I just found the column flag_data value of system_config_snapshot line is trimmed.



                                                        I had to change it to MEDIUMTEXT for this column flag.flag_data.






                                                        share|improve this answer




























                                                          0














                                                          I found out that whole serialized data cannot be fit into a database MySQL table column with TEXT data type.
                                                          I just found the column flag_data value of system_config_snapshot line is trimmed.



                                                          I had to change it to MEDIUMTEXT for this column flag.flag_data.






                                                          share|improve this answer


























                                                            0












                                                            0








                                                            0







                                                            I found out that whole serialized data cannot be fit into a database MySQL table column with TEXT data type.
                                                            I just found the column flag_data value of system_config_snapshot line is trimmed.



                                                            I had to change it to MEDIUMTEXT for this column flag.flag_data.






                                                            share|improve this answer













                                                            I found out that whole serialized data cannot be fit into a database MySQL table column with TEXT data type.
                                                            I just found the column flag_data value of system_config_snapshot line is trimmed.



                                                            I had to change it to MEDIUMTEXT for this column flag.flag_data.







                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Oct 16 '18 at 12:20









                                                            KirbyKirby

                                                            421411




                                                            421411























                                                                0














                                                                I personally found this issue reared it's head running the command:



                                                                php bin/magento setup:upgrade


                                                                After a migration. I found out that I was missing the "crypt" hash key in src/app/etc/env.php:



                                                                <?php
                                                                return [
                                                                'backend' => [
                                                                'frontName' => 'admin'
                                                                ],
                                                                'crypt' => [
                                                                'key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
                                                                ],

                                                                ...


                                                                Ensure this is not empty and preferably matches your projects' other environments!





                                                                share




























                                                                  0














                                                                  I personally found this issue reared it's head running the command:



                                                                  php bin/magento setup:upgrade


                                                                  After a migration. I found out that I was missing the "crypt" hash key in src/app/etc/env.php:



                                                                  <?php
                                                                  return [
                                                                  'backend' => [
                                                                  'frontName' => 'admin'
                                                                  ],
                                                                  'crypt' => [
                                                                  'key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
                                                                  ],

                                                                  ...


                                                                  Ensure this is not empty and preferably matches your projects' other environments!





                                                                  share


























                                                                    0












                                                                    0








                                                                    0







                                                                    I personally found this issue reared it's head running the command:



                                                                    php bin/magento setup:upgrade


                                                                    After a migration. I found out that I was missing the "crypt" hash key in src/app/etc/env.php:



                                                                    <?php
                                                                    return [
                                                                    'backend' => [
                                                                    'frontName' => 'admin'
                                                                    ],
                                                                    'crypt' => [
                                                                    'key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
                                                                    ],

                                                                    ...


                                                                    Ensure this is not empty and preferably matches your projects' other environments!





                                                                    share













                                                                    I personally found this issue reared it's head running the command:



                                                                    php bin/magento setup:upgrade


                                                                    After a migration. I found out that I was missing the "crypt" hash key in src/app/etc/env.php:



                                                                    <?php
                                                                    return [
                                                                    'backend' => [
                                                                    'frontName' => 'admin'
                                                                    ],
                                                                    'crypt' => [
                                                                    'key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
                                                                    ],

                                                                    ...


                                                                    Ensure this is not empty and preferably matches your projects' other environments!






                                                                    share











                                                                    share


                                                                    share










                                                                    answered 2 mins ago









                                                                    Chris RogersChris Rogers

                                                                    228210




                                                                    228210






























                                                                        draft saved

                                                                        draft discarded




















































                                                                        Thanks for contributing an answer to Magento Stack Exchange!


                                                                        • Please be sure to answer the question. Provide details and share your research!

                                                                        But avoid



                                                                        • Asking for help, clarification, or responding to other answers.

                                                                        • Making statements based on opinion; back them up with references or personal experience.


                                                                        To learn more, see our tips on writing great answers.




                                                                        draft saved


                                                                        draft discarded














                                                                        StackExchange.ready(
                                                                        function () {
                                                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f194010%2fmagento-2-2-unable-to-unserialize-value%23new-answer', 'question_page');
                                                                        }
                                                                        );

                                                                        Post as a guest















                                                                        Required, but never shown





















































                                                                        Required, but never shown














                                                                        Required, but never shown












                                                                        Required, but never shown







                                                                        Required, but never shown

































                                                                        Required, but never shown














                                                                        Required, but never shown












                                                                        Required, but never shown







                                                                        Required, but never shown







                                                                        Popular posts from this blog

                                                                        Magento 2 controller redirect on button click in phtml file

                                                                        Polycentropodidae