diff --git a/NEWS b/NEWS index 6798a29e7e60e..15b6a94e0c3d5 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ PHP NEWS . Fixed bug GH-11997 (ctype_alnum 5 times slower in PHP 8.1 or greater). (nielsdos) +- DOM: + . Restore old namespace reconciliation behaviour. (nielsdos) + - Filter: . Fix explicit FILTER_REQUIRE_SCALAR with FILTER_CALLBACK (ilutov) diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index ba532045186e5..5eea6840b66c6 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1489,11 +1489,16 @@ static void dom_reconcile_ns_internal(xmlDocPtr doc, xmlNodePtr nodep, xmlNodePt static void dom_libxml_reconcile_ensure_namespaces_are_declared(xmlNodePtr nodep) { + /* Ideally we'd use the DOM-wrapped version, but we cannot: https://github.com/php/php-src/pull/12308. */ +#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 index 324bf9508d5ce..1c9ec95418e01 100644 --- a/ext/dom/tests/bug47847.phpt +++ b/ext/dom/tests/bug47847.phpt @@ -2,6 +2,8 @@ Bug #47847 (importNode loses the namespace of an XML element) --EXTENSIONS-- dom +--XFAIL-- +See https://github.com/php/php-src/pull/12308 --FILE-- loadXML(<< + + + +XML); +$dom2 = new DOMDocument(); +$dom2->loadXML(''); +$wsse = $dom2->importNode($dom1->documentElement, true); +$dom2->firstChild->firstChild->appendChild($wsse); +echo $dom2->saveXML(); + +?> +--EXPECT-- + + + + +