cvs: php-src /ext/dom node.c
| From: | Rob Richards | Date: | Fri, 18 Feb 2005 11:47:21 +0000 |
| Subject: | cvs: php-src /ext/dom node.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-30474@lists.php.net to get a copy of this message | ||
rrichards Fri Feb 18 06:47:21 2005 EDT
Modified files:
/php-src/ext/dom node.c
Log:
Fixed bug #32011 (Fragments which replaced Nodes are not globaly useable)
http://cvs.php.net/diff.php/php-src/ext/dom/node.c?r1=1.31&r2=1.32&ty=u
Index: php-src/ext/dom/node.c
diff -u php-src/ext/dom/node.c:1.31 php-src/ext/dom/node.c:1.32
--- php-src/ext/dom/node.c:1.31 Thu Nov 18 14:54:30 2004
+++ php-src/ext/dom/node.c Fri Feb 18 06:47:20 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: node.c,v 1.31 2004/11/18 19:54:30 rrichards Exp $ */
+/* $Id: node.c,v 1.32 2005/02/18 11:47:20 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1129,9 +1129,55 @@
}
if (foundoldchild) {
+ xmlNodePtr node;
zval *rv = NULL;
- if (oldchild != newchild) {
- xmlNodePtr node;
+
+ if (newchild->type == XML_DOCUMENT_FRAG_NODE) {
+ xmlNodePtr fragment, prevsib, nextsib;
+ fragment = newchild;
+ prevsib = oldchild->prev;
+ nextsib = oldchild->next;
+
+ newchild = fragment->children;
+
+ xmlUnlinkNode(oldchild);
+
+ if (prevsib == NULL && nextsib == NULL) {
+ nodep->children = newchild;
+ nodep->last = fragment->last;
+ } else {
+ if (newchild) {
+ prevsib->next = newchild;
+ newchild->prev = prevsib;
+
+ fragment->last->next = nextsib;
+ if (nextsib) {
+ nextsib->prev = fragment->last;
+ } else {
+ nodep->last = fragment->last;
+ }
+ }
+ }
+ node = newchild;
+ while (node != NULL) {
+ node->parent = nodep;
+ if (node->doc != nodep->doc) {
+ xmlSetTreeDoc(node, nodep->doc);
+ if (node->_private != NULL) {
+ newchildobj = node->_private;
+ newchildobj->document = intern->document;
+ php_libxml_increment_doc_ref((php_libxml_node_object *)newchildobj, NULL TSRMLS_CC);
+ }
+ }
+ if (node == fragment->last) {
+ break;
+ }
+ node = node->next;
+ }
+
+ fragment->children = NULL;
+ fragment->last = NULL;
+ } else if (oldchild != newchild) {
if (newchild->doc == NULL && nodep->doc != NULL) {
xmlSetTreeDoc(newchild, nodep->doc);
newchildobj->document = intern->document;
@@ -1146,7 +1192,6 @@
php_dom_throw_error(NOT_FOUND_ERR, dom_get_strict_error(intern->document) TSRMLS_CC);
RETURN_FALSE;
}
-
}
/* }}} end dom_node_replace_child */