diff options
author | Christian Stocker <chregu@php.net> | 2002-08-14 16:53:56 +0000 |
---|---|---|
committer | Christian Stocker <chregu@php.net> | 2002-08-14 16:53:56 +0000 |
commit | ce71fe02883a97081ac7f858d82f64a5347db085 (patch) | |
tree | ec860844a783b8850b860b18871ea1109dc9b3d5 | |
parent | d10bf420298ab6d77460803c04ff650acb09307a (diff) | |
download | php-git-ce71fe02883a97081ac7f858d82f64a5347db085.tar.gz |
DomNode->replace_node moves instead of copies node.
-rw-r--r-- | ext/domxml/php_domxml.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index b95306753e..039c95648d 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -2320,7 +2320,7 @@ PHP_FUNCTION(domxml_node_unlink_node) PHP_FUNCTION(domxml_node_replace_node) { zval *id, *rv = NULL, *node; - xmlNodePtr repnode, nodep, new_repnode; + xmlNodePtr repnode, nodep, old_repnode; int ret; DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep); @@ -2331,23 +2331,9 @@ PHP_FUNCTION(domxml_node_replace_node) DOMXML_GET_OBJ(repnode, node, le_domxmlnodep); - /* check if the new node is already part of the document. In such a case - * we better make a copy to prevent changing identical nodes at different - * positions in the document at the same time. - * A node created with e.g. create_element() doesn't have parents. - */ - if(repnode->parent) { - if (NULL == (new_repnode = xmlCopyNode(repnode, 1))) { - php_error(E_WARNING, "%s(): unable to clone node", get_active_function_name(TSRMLS_C)); - RETURN_FALSE; - } - } else { - new_repnode = repnode; - } - - repnode = xmlReplaceNode(nodep, new_repnode); + old_repnode = xmlReplaceNode(nodep, repnode); - DOMXML_RET_OBJ(rv, nodep, &ret); + DOMXML_RET_OBJ(rv, old_repnode, &ret); } /* }}} */ |