rrichards Fri Feb 18 06:47:50 2005 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/dom node.c
Log:
MFH: 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.29.2.2&r2=1.29.2.3&ty=u
Index: php-src/ext/dom/node.c
diff -u php-src/ext/dom/node.c:1.29.2.2 php-src/ext/dom/node.c:1.29.2.3
--- php-src/ext/dom/node.c:1.29.2.2 Thu Nov 18 14:55:00 2004
+++ php-src/ext/dom/node.c Fri Feb 18 06:47:50 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: node.c,v 1.29.2.2 2004/11/18 19:55:00 rrichards Exp $ */
+/* $Id: node.c,v 1.29.2.3 2005/02/18 11:47:50 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 */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php