Created
September 3, 2018 09:20
-
-
Save manojind/9f18bbecaeb3e2bbfb056a634ade62a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ROOT directory | |
1. public_html/vendor/magento/framework/Serialize/Serializer/Json.php | |
2. Just replace below fucntion (unserialize) and add new function OR just download 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; | |
} | |
Thanks for help
Welcome
Let me know if you need any other help ?
Thanks
while upgrading to Magento 2.3 the same issue occured "Unable to unserialize value, string is corrupted."
The above code does not solve my problem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks
I just updated magneto 2.2.5 but there was lot off error Unserialize Value solved lot of but there still lot off issues like Module chema_version and data_version .
Created 20 minutes ago •