Skip to content

Avoid reconciling when cloning into the same document #14921

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

Merged
merged 1 commit into from
Jul 12, 2024
Merged
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: 3 additions & 1 deletion ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,9 @@ xmlNodePtr dom_clone_node(php_dom_libxml_ns_mapper *ns_mapper, xmlNodePtr node,

if (ns_mapper != NULL) {
xmlNodePtr clone = dom_clone_helper(ns_mapper, node, doc, recursive);
if (EXPECTED(clone != NULL)) {
if (EXPECTED(clone != NULL) && doc != node->doc) {
/* We only need to reconcile the namespace when the document changes because the namespaces have to be
* put into their respective namespace mapper. */
if (clone->type == XML_DOCUMENT_NODE || clone->type == XML_HTML_DOCUMENT_NODE || clone->type == XML_DOCUMENT_FRAG_NODE) {
for (xmlNodePtr child = clone->children; child != NULL; child = child->next) {
php_dom_libxml_reconcile_modern(ns_mapper, child);
Expand Down
Loading