From ee19eac05d0b00c9547e32e0ed72ffc75ecb97a9 Mon Sep 17 00:00:00 2001 From: Deltik Date: Mon, 5 Feb 2018 09:28:57 -0600 Subject: [PATCH] PHP 7.2 consistency hack in xmlClass::xml2array() This is a workaround to make the output of xmlClass::xml2array() in PHP 7.2 equal to that of prior PHP versions. Consider this fix to be a part 2 of #3026. PHP 7.2 changed the behavior of how we extract tags from SimpleXMLElement resources. This hack adds a toleration for either the PHP 7.2 behavior and the past behavior, which allows consistent parsing of XML files. One side effect of this change is the fixing of an innocuous bug that provided blank values in some "@value" keys that should not have existed in the first place. This should hopefully have no practical effect on current uses of the modified method. Fixes: #3027 --- e107_handlers/xml_class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index fc64e5add..51d010605 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -561,16 +561,17 @@ class xmlClass //loop through tags foreach ($tags as $tag) { + if(is_int($tag)) continue; switch($tag) { case '@attributes': $tmp = (array) $xml->attributes(); $ret['@attributes'] = $tmp['@attributes']; - if($count_tags == 1) //only attributes & possible value + if($count_tags == 1 || ['@attributes', 0] === $tags) //only attributes & possible value { $ret[$this->_optValueKey] = trim((string) $xml); - return $ret; + //return $ret; } break;