mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Merge pull request #3026 from Deltik/fix-3018
Fixes: #3018 Sanity check in xmlClass::xml2array() for PHP 7.2
This commit is contained in:
@@ -553,7 +553,7 @@ class xmlClass
|
||||
}
|
||||
|
||||
//Recursive calls start here
|
||||
if($tags)
|
||||
if(self::is_assoc($tags))
|
||||
{
|
||||
$tags = array_keys($tags);
|
||||
$count_tags = count($tags);
|
||||
@@ -749,6 +749,25 @@ class xmlClass
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the provided variable is an associative array
|
||||
*
|
||||
* This method is necessary because since PHP 7.2, get_object_vars() on
|
||||
* a SimpleXMLElement object began returning sequential arrays, and
|
||||
* xmlClass::xml2array() interpreted the sequence as XML tags.
|
||||
*
|
||||
* See https://github.com/e107inc/e107/issues/3018 for details.
|
||||
*
|
||||
* @param array $array The variable to check
|
||||
* @return boolean true if the provided variable is an associative array,
|
||||
* false if it's a sequential array or anything else
|
||||
*/
|
||||
private static function is_assoc($array)
|
||||
{
|
||||
if (!is_array($array) || array() === $array) return false;
|
||||
return array_keys($array) !== range(0, count($array) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load XML file and parse it (optional)
|
||||
*
|
||||
|
Reference in New Issue
Block a user