Skip to content

Commit

Permalink
Closes #3305 Added a backward compatibility fix for buggy array stora…
Browse files Browse the repository at this point in the history
…ge data.
  • Loading branch information
CaMer0n committed Jul 22, 2018
1 parent 9697e11 commit 262dc7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions e107_handlers/core_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class e_array {
* Returns an array from stored array data in php serialized, e107 var_export and json-encoded data.
*
* @param string $ArrayData
* @return array stored data
* @return array|bool stored data
*/
public function unserialize($ArrayData)
{
Expand Down Expand Up @@ -461,12 +461,17 @@ public function unserialize($ArrayData)

$ArrayData = trim($ArrayData);

if(strpos($ArrayData, "\$data = ") === 0) // Fix for buggy old value.
{
$ArrayData = substr($ArrayData,8);
}

if(strtolower(substr($ArrayData,0,5)) != 'array')
{
return false;
}

if(strpos($ArrayData,"0 => \'")!=false)
if(strpos($ArrayData," => \'") !== false)
{
$ArrayData = stripslashes($ArrayData);
}
Expand Down
8 changes: 4 additions & 4 deletions e107_handlers/e107_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1751,17 +1751,17 @@ public static function user($uid=null)
* Return a string containg exported array data. - preferred.
*
* @param array $ArrayData array to be stored
* @param bool $AddSlashes default false, add slashes for db storage, else false
* @return string
* @param bool|string $mode true = var_export with addedslashes, false = var_export (default), 'json' = json encoded
* @return array|string
*/
public static function serialize($ArrayData, $AddSlashes = false)
public static function serialize($ArrayData, $mode = false)
{
if(empty($ArrayData))
{
return array();
}

return self::getArrayStorage()->serialize($ArrayData, $AddSlashes);
return self::getArrayStorage()->serialize($ArrayData, $mode);
}

/**
Expand Down

0 comments on commit 262dc7f

Please sign in to comment.