Skip to content
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

Restore old namespace reconciliation behaviour #12308

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,11 +1489,15 @@ static void dom_reconcile_ns_internal(xmlDocPtr doc, xmlNodePtr nodep, xmlNodePt

static void dom_libxml_reconcile_ensure_namespaces_are_declared(xmlNodePtr nodep)
{
#if 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment to explain why this code is dead?

/* Put on stack to avoid allocation.
* Although libxml2 currently does not use this for the reconciliation, it still
* makes sense to do this just in case libxml2's internal change in the future. */
xmlDOMWrapCtxt dummy_ctxt = {0};
xmlDOMWrapReconcileNamespaces(&dummy_ctxt, nodep, /* options */ 0);
#else
xmlReconciliateNs(nodep->doc, nodep);
#endif
}

void dom_reconcile_ns(xmlDocPtr doc, xmlNodePtr nodep) /* {{{ */
Expand Down
12 changes: 6 additions & 6 deletions ext/dom/tests/bug47530.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ test_appendChild_with_shadowing();
--EXPECT--
-- Test document fragment with import --
<?xml version="1.0"?>
<html xmlns="https://php.net/something" xmlns:ns="https://php.net/whatever"><element ns:foo="https://php.net/bar"/></html>
<html xmlns="https://php.net/something" xmlns:ns="https://php.net/whatever"><default:element xmlns:default="https://php.net/something" ns:foo="https://php.net/bar"/></html>
-- Test document fragment without import --
<?xml version="1.0"?>
<html xmlns=""><element xmlns:foo="https://php.net/bar"><foo:bar/><bar xmlns=""/></element></html>
<html xmlns=""><element xmlns:foo="https://php.net/bar"><foo:bar/><bar/></element></html>
string(7) "foo:bar"
string(19) "https://php.net/bar"
-- Test document import --
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>Test-Text</p>
</div>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:default="http://www.w3.org/1999/xhtml">
<default:div xmlns="http://www.w3.org/1999/xhtml">
<default:p>Test-Text</default:p>
</default:div>
</feed>
-- Test partial document import --
<?xml version="1.0"?>
Expand Down
27 changes: 0 additions & 27 deletions ext/dom/tests/bug47847.phpt

This file was deleted.

29 changes: 0 additions & 29 deletions ext/dom/tests/bug55294.phpt

This file was deleted.

27 changes: 27 additions & 0 deletions ext/dom/tests/specific_namespace_behaviour.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
DOM: specific namespace behaviour for applications with fixed serialization requirements
--EXTENSIONS--
dom
--FILE--
<?php

$dom1 = new DOMDocument();
$dom1->loadXML(<<<XML
<wsse:Security xmlns:wsse="foo:bar">
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
</ds:Signature>
</wsse:Security>
XML);
$dom2 = new DOMDocument();
$dom2->loadXML('<xml><child/></xml>');
$wsse = $dom2->importNode($dom1->documentElement, true);
$dom2->firstChild->firstChild->appendChild($wsse);
echo $dom2->saveXML();

?>
--EXPECT--
<?xml version="1.0"?>
<xml><child><wsse:Security xmlns:wsse="foo:bar" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
</ds:Signature>
</wsse:Security></child></xml>