Skip to content

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

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

[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

SimpleXMLElement::addChild() stored the QName prefix as the iteration namespace filter in href mode, so property access on the returned element compared the prefix against namespace hrefs and never matched children that asXML() shows: $c->inner was empty. The element now derives its filter from the namespace attached to the created node (newnode->ns->prefix) and switches to prefix mode, which also covers qname prefixes differing from the resolved namespace. A node_as_zval_str()/node_as_zval() call-site audit found no other offender; a new phpt fails unpatched and passes patched.

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
@iliaal

iliaal commented Sep 6, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream as php#23599.

@iliaal iliaal closed this Sep 6, 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