rrichards Sat Dec 27 05:29:53 2003 EDT Modified files: /php-src/ext/dom node.c Log: Fixed bug #26723 (domNode::appendChild() changes child node namespace) apply fix to insertBefore and replaceChild Index: php-src/ext/dom/node.c diff -u php-src/ext/dom/node.c:1.19 php-src/ext/dom/node.c:1.20 --- php-src/ext/dom/node.c:1.19 Tue Dec 9 16:56:42 2003 +++ php-src/ext/dom/node.c Sat Dec 27 05:29:52 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: node.c,v 1.19 2003/12/09 21:56:42 rrichards Exp $ */ +/* $Id: node.c,v 1.20 2003/12/27 10:29:52 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -56,6 +56,22 @@ {NULL, NULL, NULL} }; +static void dom_reconcile_ns(xmlDocPtr doc, xmlNodePtr nodep) { + xmlNsPtr nsptr; + + if (nodep->type == XML_ELEMENT_NODE) { + /* Following if block primarily used for inserting nodes created via createElementNS */ + if (nodep->nsDef != NULL && nodep->nsDef->href != NULL) { + if((nsptr = xmlSearchNsByHref(doc, nodep->parent, nodep->nsDef->href)) && + (nodep->nsDef->prefix == NULL || xmlStrEqual(nsptr->prefix, nodep->nsDef->prefix))) { + dom_set_old_ns(doc, nodep->ns); + nodep->nsDef = NULL; + } + } + xmlReconciliateNs(doc, nodep); + } +} + /* {{{ proto nodeName string readonly=yes URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-F68D095 @@ -867,6 +883,8 @@ RETURN_FALSE; } + dom_reconcile_ns(parentp->doc, new_child); + DOM_RET_OBJ(rv, new_child, &ret, intern); } @@ -941,6 +959,7 @@ php_libxml_increment_doc_ref((php_libxml_node_object *)newchildobj, NULL TSRMLS_CC); } node = xmlReplaceNode(oldchild, newchild); + dom_reconcile_ns(nodep->doc, newchild); } DOM_RET_OBJ(rv, oldchild, &ret, intern); return; @@ -1015,7 +1034,6 @@ zval *id, *node, *rv = NULL; xmlNodePtr child, nodep, new_child = NULL; dom_object *intern, *childobj; - xmlNsPtr nsptr; int ret, stricterror; DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); @@ -1101,14 +1119,7 @@ RETURN_FALSE; } - if (new_child->nsDef != NULL && new_child->type == XML_ELEMENT_NODE && new_child->nsDef->href != NULL) { - if((nsptr = xmlSearchNsByHref(nodep->doc, new_child->parent, new_child->nsDef->href)) && - (new_child->nsDef->prefix == NULL || xmlStrEqual(nsptr->prefix, new_child->nsDef->prefix))) { - dom_set_old_ns(nodep->doc, new_child->ns); - new_child->nsDef = NULL; - new_child->ns = nsptr; - } - } + dom_reconcile_ns(nodep->doc, new_child); DOM_RET_OBJ(rv, new_child, &ret, intern); }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php