Skip to content

Conversation

@tim-reynolds
Copy link
Contributor

#1035

A bug in the appendChild method of Magento\Framework\Simplexml\Element.php causes values to be lost in very specific cases. This will fix it. The existing unit test for appendChild has been updated as well.

Bug: When appending a node that has an attribute and no child nodes, the code will take the code path for having children. This is because the result of $source->children() evaluates to TRUE when a node has attributes and no children.
Example:

$root = simplexml_load_string('<root/>', 'Magento\Framework\Simplexml\Element');
$append = simplexml_load_string('<child attr="abc">Text</child>', 'Magento\Framework\Simplexml\Element');
$root->appendChild($append);
echo $root->asNiceXml();

Should output:

<root>
    <child attr="abc">Text</child>
</root>

Actually outputs:

<root>
    <child attr="abc" />
</root>

Fix: Changing to call from [children()] to [count()] fixes the issue.

magento#1035

A bug in the appendNode method of Magento\Framework\Simplexml\Element.php causes values to be lost in very specific cases. This will fix it. The existing unit test for appendNode has been updated as well.

Bug: When appending a node that has an attribute and no child nodes, the code will take the code path for having children. This is because the result of $source->children() evaluates to TRUE when a node has attributes and no children.

Fix: Changing to call from [children()] to [count()] fixes the issue.
@anupdugar
Copy link
Contributor

Thanks for submitting this pull request. We will process it internally through ticket MAGETWO-34069 and merge your pull request after that.

@vpelipenko vpelipenko added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Feb 23, 2015
@anupdugar anupdugar added Progress: accept in progress and removed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Feb 24, 2015
@magento-team magento-team merged commit 4a92a64 into magento:develop Mar 6, 2015
magento-team pushed a commit that referenced this pull request Apr 21, 2017
[Troll] MAGETWO-66143: Increase api coverage for catalog, catalogStaging and advancedCatalog modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants