Skip to content

Instantly share code, notes, and snippets.

@swtaarrs
Created November 6, 2014 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swtaarrs/2577519dbcf6e6e062a2 to your computer and use it in GitHub Desktop.
Save swtaarrs/2577519dbcf6e6e062a2 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..03e685f 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 (domnewchildnode->doc().get()) {
+ removeOrphanIfNeeded(*domnewchildnode->doc_data()->m_orphans,
+ domnewchildnode->m_node);
+ }
+ return create_node_object(oldchild, data->doc(), oldchild != newchild);
}
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