Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getChildren must be compatible with SimpleXMLElement with PHP 8 #1613

Merged
merged 2 commits into from
May 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions app/code/core/Mage/Api/Model/Wsdl/Config/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -170,13 +170,24 @@ 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
*
* @param Varien_Simplexml_Element $source
* @return array
*/
public function getChildren($source)
protected static function _getChildren($source)
{
$children = array();
$namespaces = $source->getNamespaces(true);
Expand All @@ -200,12 +211,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;
}
Expand Down