msopacua Tue Sep 9 15:43:46 2003 EDT
Added files: (Branch: PHP_4_3)
/php-src/ext/domxml/tests bug23326.phpt
Modified files:
/php-src/ext/domxml php_domxml.c
Log:
Fix #23326: Attributes via append_child not supported
Add testcase
Index: php-src/ext/domxml/php_domxml.c
diff -u php-src/ext/domxml/php_domxml.c:1.218.2.30
php-src/ext/domxml/php_domxml.c:1.218.2.31
--- php-src/ext/domxml/php_domxml.c:1.218.2.30 Fri Aug 29 13:36:34 2003
+++ php-src/ext/domxml/php_domxml.c Tue Sep 9 15:43:44 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_domxml.c,v 1.218.2.30 2003/08/29 17:36:34 rrichards Exp $ */
+/* $Id: php_domxml.c,v 1.218.2.31 2003/09/09 19:43:44 msopacua Exp $ */
/* TODO
* - Support Notation Nodes
@@ -2425,11 +2425,6 @@
DOMXML_GET_OBJ(child, node, le_domxmlnodep);
- if (child->type == XML_ATTRIBUTE_NODE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append attribute
node");
- RETURN_FALSE;
- }
-
/* XXX:ls */
if (child == parent) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append node to
itself");
@@ -2469,6 +2464,28 @@
}
}
/* end libxml2 code */
+ else if (child->type == XML_ATTRIBUTE_NODE) {
+ if (parent->properties != NULL) {
+ /* Check if an attribute with the same name exists */
+ xmlAttrPtr foundattrp;
+ if (child->ns == NULL)
+ foundattrp = xmlHasProp(parent, child->name);
+ else
+ foundattrp = xmlHasNsProp(parent, child->name,
child->ns->href);
+ if ((foundattrp != NULL) && (foundattrp != (xmlAttrPtr)
child)) {
+ xmlUnlinkNode((xmlNodePtr) foundattrp);
+ (void)xmlCopyProp(parent, (xmlAttrPtr) child);
+ /* We're in the dark here, what happened to the
parent, let's
+ * assume it's handled properly and return the new(?)
parent
+ */
+ new_child = parent;
+ }
+ }
+ /* For all other intents and purposes fall through to the xmlAddChild
+ * call
+ */
+ }
+
if (NULL == new_child) {
new_child = xmlAddChild(parent, child);
Index: php-src/ext/domxml/tests/bug23326.phpt
+++ php-src/ext/domxml/tests/bug23326.phpt
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php