diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index ba532045186e5..6b62dee314f97 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -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 /* 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) /* {{{ */ diff --git a/ext/dom/tests/bug47530.phpt b/ext/dom/tests/bug47530.phpt index 0fb990e0e7bff..301a418fbe841 100644 --- a/ext/dom/tests/bug47530.phpt +++ b/ext/dom/tests/bug47530.phpt @@ -118,18 +118,18 @@ test_appendChild_with_shadowing(); --EXPECT-- -- Test document fragment with import -- - + -- Test document fragment without import -- - + string(7) "foo:bar" string(19) "https://php.net/bar" -- Test document import -- - -
-

Test-Text

-
+ + + Test-Text + -- Test partial document import -- diff --git a/ext/dom/tests/bug47847.phpt b/ext/dom/tests/bug47847.phpt deleted file mode 100644 index 324bf9508d5ce..0000000000000 --- a/ext/dom/tests/bug47847.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Bug #47847 (importNode loses the namespace of an XML element) ---EXTENSIONS-- -dom ---FILE-- -loadXML(<< - - - - - -XML); - -$aDOM = new DOMDocument(); -$imported = $aDOM->importNode($fromdom->documentElement->firstElementChild, true); -$aDOM->appendChild($imported); - -echo $aDOM->saveXML(); -?> ---EXPECT-- - - - - diff --git a/ext/dom/tests/bug55294.phpt b/ext/dom/tests/bug55294.phpt deleted file mode 100644 index 19534955029bc..0000000000000 --- a/ext/dom/tests/bug55294.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Bug #55294 (DOMDocument::importNode shifts namespaces when "default" namespace exists) ---EXTENSIONS-- -dom ---FILE-- -loadXML(<< - - - - -EOXML -); - -$bDOM = new DOMDocument(); -$node = $bDOM->importNode($aDOM->getElementsByTagNameNS('http://example.com/A', 'B')->item(0), true); -$bDOM->appendChild($node); - -echo $bDOM->saveXML(), "\n"; - -?> ---EXPECT-- - - - - diff --git a/ext/dom/tests/specific_namespace_behaviour.phpt b/ext/dom/tests/specific_namespace_behaviour.phpt new file mode 100644 index 0000000000000..e6499e6ba5225 --- /dev/null +++ b/ext/dom/tests/specific_namespace_behaviour.phpt @@ -0,0 +1,27 @@ +--TEST-- +DOM: specific namespace behaviour for applications with fixed serialization requirements +--EXTENSIONS-- +dom +--FILE-- +loadXML(<< + + + +XML); +$dom2 = new DOMDocument(); +$dom2->loadXML(''); +$wsse = $dom2->importNode($dom1->documentElement, true); +$dom2->firstChild->firstChild->appendChild($wsse); +echo $dom2->saveXML(); + +?> +--EXPECT-- + + + + +