Skip to content

[SimpleXML] Fix namespace filter on element returned by addChild() - #259

Open
iliaal wants to merge 1 commit into
PHP-8.4from
fix/r7h-84
Open

[SimpleXML] Fix namespace filter on element returned by addChild()#259
iliaal wants to merge 1 commit into
PHP-8.4from
fix/r7h-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

The SimpleXMLElement returned by SimpleXMLElement::addChild() stored the QName prefix (e.g. "a" from "a:kid") as the iteration namespace filter in href mode, so any subsequent property access on that element compared the prefix against namespace hrefs and never matched the children that asXML() shows; $c->inner was empty and isset($c->inner) false even though the child element existed. The fix derives the filter from the namespace actually attached to the newly created node (newnode->ns->prefix) and switches to prefix mode, which also handles qname prefixes that differ from the resolved namespace declaration. A sibling audit of node_as_zval_str()/node_as_zval() call sites found no other site passing a QName prefix in href mode. Red/green verified: new phpt fails unpatched, passes patched, ext/simplexml suite has zero failures.

The SimpleXMLElement wrapper returned by addChild() stored the QName
prefix as the iteration namespace filter in href mode, so property
accesses on the returned element compared the prefix against namespace
hrefs and never matched the children that asXML() shows. Derive the
filter from the namespace actually attached to the new node and use
prefix mode; sibling audit found no other call site passing a prefix in
href mode.
@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant