mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
DomNode->replace_node moves instead of copies node.
This commit is contained in:
parent
d10bf42029
commit
ce71fe0288
1 changed files with 3 additions and 17 deletions
|
@ -2320,7 +2320,7 @@ PHP_FUNCTION(domxml_node_unlink_node)
|
||||||
PHP_FUNCTION(domxml_node_replace_node)
|
PHP_FUNCTION(domxml_node_replace_node)
|
||||||
{
|
{
|
||||||
zval *id, *rv = NULL, *node;
|
zval *id, *rv = NULL, *node;
|
||||||
xmlNodePtr repnode, nodep, new_repnode;
|
xmlNodePtr repnode, nodep, old_repnode;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
|
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);
|
DOMXML_GET_OBJ(repnode, node, le_domxmlnodep);
|
||||||
|
|
||||||
/* check if the new node is already part of the document. In such a case
|
old_repnode = xmlReplaceNode(nodep, repnode);
|
||||||
* 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);
|
DOMXML_RET_OBJ(rv, old_repnode, &ret);
|
||||||
|
|
||||||
DOMXML_RET_OBJ(rv, nodep, &ret);
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue