Skip to content

ext/dom: Restore the XPath context after a reentrant evaluation - #24125

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/aph-dom-xpath-reentrant-0bc-84-work
Open

iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/aph-dom-xpath-reentrant-0bc-84-work

Conversation

@iliaal

@iliaal iliaal commented Oct 4, 2026

Copy link
Copy Markdown
Member

When a php:function() callback evaluates another expression on the same DOMXPath or Dom\XPath, the inner evaluation used to clear the shared libxml context's node and namespace list on its way out, so the outer evaluation resumed without them: later predicate steps matched nothing or failed with "Undefined namespace prefix". php_xpath_eval() now restores the previous node and namespace list instead of clearing them.

php_xpath_eval() cleared the shared xmlXPathContext's node after every
evaluation, and with registerNodeNS (the default) its namespace list as
well. When a php:function() callback evaluated another expression on the
same DOMXPath or Dom\XPath, the outer evaluation resumed without its
context node and in-scope namespaces, so later predicate steps matched
nothing or failed with "Undefined namespace prefix". The previous node
and namespace list are now restored instead.
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.

1 participant