Skip to content

Bug in Magento\Framework\Simplexml\Element::appendChild #1035

Closed
@tim-reynolds

Description

@tim-reynolds

The bug is in the call to:
$source->children()

If an XML node has no child nodes and no attributes, this resolves to FALSE
However, if the XML node has no children and has one or more attributes it resolves to TRUE when clearly it should not.

See the line of code in question:
https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/Simplexml/Element.php#L329

This line needs to be changed to

if(count($source->children())) {

Please see this Gist
https://gist.github.com/tim-reynolds/ac20289acdcfcde3633f

The bug exists in Magento 1.X as well as 2.0.

I would really blame PHP SimpleXMLElement but we can't readily fix that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions