Skip to content

Commit 70248fc

Browse files
Fix getChildren must be compatible with SimpleXMLElement with PHP 8 (OpenMage#1613)
* Alternative solution for OpenMage#1603 (Fix getChildren must be compatible with SimpleXMLElement with PHP 8) * Add back original method as deprecated.
1 parent 9b04ad2 commit 70248fc

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

app/code/core/Mage/Api/Model/Wsdl/Config/Element.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function extend($source, $overwrite = false)
4444
return $this;
4545
}
4646

47-
foreach ($this->getChildren($source) as $namespace => $children) {
47+
foreach (self::_getChildren($source) as $namespace => $children) {
4848
foreach ($children as $child) {
4949
$this->extendChild($child, $overwrite, $namespace);
5050
}
@@ -70,7 +70,7 @@ public function extendChild($source, $overwrite = false, $elmNamespace = '')
7070
$sourceName = $source->getName();
7171

7272
// here we have children of our source node
73-
$sourceChildren = $this->getChildren($source);
73+
$sourceChildren = self::_getChildren($source);
7474

7575
if ($elmNamespace == '') {
7676
$elmNamespace = null;
@@ -81,7 +81,7 @@ public function extendChild($source, $overwrite = false, $elmNamespace = '')
8181
$elm = $this->getElementByName($source, $elmNamespace);
8282
if (!is_null($elm)) {
8383
// if target already has children return without regard
84-
if ($this->getChildren($elm)) {
84+
if (self::_getChildren($elm)) {
8585
return $this;
8686
}
8787
if ($overwrite) {
@@ -170,13 +170,24 @@ public function getAttributes($source, $namespace = null)
170170
return $attributes;
171171
}
172172

173+
/**
174+
* @deprecated due to conflict with PHP8 parent class update
175+
* @param Varien_Simplexml_Element $source
176+
* @return array
177+
*/
178+
public function getChildren($source = null)
179+
{
180+
Mage::log('Use of deprecated method: '.__METHOD__);
181+
return self::_getChildren($source);
182+
}
183+
173184
/**
174185
* Return children of all namespaces
175186
*
176187
* @param Varien_Simplexml_Element $source
177188
* @return array
178189
*/
179-
public function getChildren($source)
190+
protected static function _getChildren($source)
180191
{
181192
$children = array();
182193
$namespaces = $source->getNamespaces(true);
@@ -200,12 +211,12 @@ public function getChildren($source)
200211
*/
201212
public function hasChildren()
202213
{
203-
if (!$this->getChildren($this)) {
214+
if (!self::_getChildren($this)) {
204215
return false;
205216
}
206217

207218
// simplexml bug: @attributes is in children() but invisible in foreach
208-
foreach ($this->getChildren($this) as $namespace => $children) {
219+
foreach (self::_getChildren($this) as $namespace => $children) {
209220
foreach ($children as $k => $child) {
210221
return true;
211222
}

0 commit comments

Comments
 (0)