Skip to content

Instantly share code, notes, and snippets.

@swtaarrs
Last active August 29, 2015 14:08
Show Gist options
  • Save swtaarrs/5d14284c32b5f0661924 to your computer and use it in GitHub Desktop.
Save swtaarrs/5d14284c32b5f0661924 to your computer and use it in GitHub Desktop.
diff --git a/hphp/runtime/ext/domdocument/ext_domdocument.cpp b/hphp/runtime/ext/domdocument/ext_domdocument.cpp
index 6a35725..3270d8a 100644
--- a/hphp/runtime/ext/domdocument/ext_domdocument.cpp
+++ b/hphp/runtime/ext/domdocument/ext_domdocument.cpp
@@ -2470,7 +2470,12 @@ Variant HHVM_METHOD(DOMNode, replaceChild,
xmlReplaceNode(oldchild, newchild);
dom_reconcile_ns(nodep->doc, newchild);
}
- return create_node_object(oldchild, data->doc(), false);
+
+ if (auto newchilddoc = domnewchildnode->doc_data()) {
+ removeOrphanIfNeeded(*newchilddoc->m_orphans, domnewchildnode->m_node);
+ }
+ return create_node_object(oldchild, data->doc(),
+ oldchild->parent == nullptr);
}
php_dom_throw_error(NOT_FOUND_ERR, data->doc_data()->m_stricterror);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment