-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix bug #81468: Inconsistent default namespace inheritance #9179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think the problem with Travis CI is that it tries to test against "master", although the target branch is PHP-8.0. |
I choose wrong target branch to merge at the begining. |
cc @beberlei |
Sorry i wont have time to review this PR. Many tests are good, so cautiosly optimisic about this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! It seems to me this approach is going in the right direction, but is not yet complete. Besides my comment below, DOMNode::insertBefore()
has the same issue, and maybe other methods, too.
ext/dom/node.c
Outdated
@@ -1220,6 +1220,9 @@ PHP_METHOD(DOMNode, appendChild) | |||
} | |||
|
|||
if (new_child == NULL) { | |||
if (!child->ns && nodep->nsDef) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this shouldn't be:
if (!child->ns && nodep->nsDef) { | |
if (!child->ns && nodep->ns) { |
That would solve:
$dom = new \DOMDocument();
$dom
->appendChild($dom->createElementNS('some:namespace', 'foo'))
->appendChild($dom->createElement('bar'))
->appendChild($dom->createElement('baz'));
echo ($xml = $dom->saveXML());
$xpath = new \DOMXPath($dom);
$xpath->registerNamespace('n', 'some:namespace');
echo count($xpath->query('/n:foo/bar')) . " should be 0\n";
echo count($xpath->query('/n:foo/n:bar')) . " should be 1\n";
echo count($xpath->query('/n:foo/n:bar/baz')) . " should be 0\n";
echo count($xpath->query('/n:foo/n:bar/n:baz')) . " should be 1\n\n";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodep->ns is not a nullptr but point to a invalid address if nodep is the root node.
This is already fixed in a better way in the new DOM classes. The old classes retain the old behaviour. |
https://bugs.php.net/bug.php?id=81468