From ea6a928d64969346064eb8a5491a8d87fa6d9f34 Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Thu, 13 May 2021 23:22:19 -0400 Subject: [PATCH 1/2] Alternative solution for #1603 (Fix getChildren must be compatible with SimpleXMLElement with PHP 8) --- app/code/core/Mage/Api/Model/Wsdl/Config/Element.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php b/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php index 0ca29cd0f15..4e032e6fedf 100644 --- a/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php +++ b/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php @@ -44,7 +44,7 @@ public function extend($source, $overwrite = false) return $this; } - foreach ($this->getChildren($source) as $namespace => $children) { + foreach (self::_getChildren($source) as $namespace => $children) { foreach ($children as $child) { $this->extendChild($child, $overwrite, $namespace); } @@ -70,7 +70,7 @@ public function extendChild($source, $overwrite = false, $elmNamespace = '') $sourceName = $source->getName(); // here we have children of our source node - $sourceChildren = $this->getChildren($source); + $sourceChildren = self::_getChildren($source); if ($elmNamespace == '') { $elmNamespace = null; @@ -81,7 +81,7 @@ public function extendChild($source, $overwrite = false, $elmNamespace = '') $elm = $this->getElementByName($source, $elmNamespace); if (!is_null($elm)) { // if target already has children return without regard - if ($this->getChildren($elm)) { + if (self::_getChildren($elm)) { return $this; } if ($overwrite) { @@ -176,7 +176,7 @@ public function getAttributes($source, $namespace = null) * @param Varien_Simplexml_Element $source * @return array */ - public function getChildren($source) + protected static function _getChildren($source) { $children = array(); $namespaces = $source->getNamespaces(true); @@ -200,12 +200,12 @@ public function getChildren($source) */ public function hasChildren() { - if (!$this->getChildren($this)) { + if (!self::_getChildren($this)) { return false; } // simplexml bug: @attributes is in children() but invisible in foreach - foreach ($this->getChildren($this) as $namespace => $children) { + foreach (self::_getChildren($this) as $namespace => $children) { foreach ($children as $k => $child) { return true; } From b5bfc3c052b7664b9401f6742bbf1a889f4f2094 Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Mon, 17 May 2021 20:04:28 -0400 Subject: [PATCH 2/2] Add back original method as deprecated. --- app/code/core/Mage/Api/Model/Wsdl/Config/Element.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php b/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php index 4e032e6fedf..e0c8b010fd8 100644 --- a/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php +++ b/app/code/core/Mage/Api/Model/Wsdl/Config/Element.php @@ -170,6 +170,17 @@ public function getAttributes($source, $namespace = null) return $attributes; } + /** + * @deprecated due to conflict with PHP8 parent class update + * @param Varien_Simplexml_Element $source + * @return array + */ + public function getChildren($source = null) + { + Mage::log('Use of deprecated method: '.__METHOD__); + return self::_getChildren($source); + } + /** * Return children of all namespaces *