summaryrefslogtreecommitdiff
path: root/ext/dom
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:37 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:37 -0400
commit10f5b47dc7c1cf2b9a00991629f43652710322d3 (patch)
tree3b727a16f652b8042d573e90f003868ffb3b56c7 /ext/dom
parent0e920280a2e04b110827bb766b9f29e3d581c4ee (diff)
downloadphp-10f5b47dc7c1cf2b9a00991629f43652710322d3.tar.gz
Imported Upstream version 5.0.5upstream/5.0.5
Diffstat (limited to 'ext/dom')
-rw-r--r--ext/dom/config.m48
-rw-r--r--ext/dom/dom_ce.h62
-rw-r--r--ext/dom/element.c29
-rw-r--r--ext/dom/node.c174
-rw-r--r--ext/dom/php_dom.c54
-rw-r--r--ext/dom/tests/bug32615.phpt84
-rw-r--r--ext/dom/tests/dom003.phpt26
-rw-r--r--ext/dom/xml_common.h12
8 files changed, 267 insertions, 182 deletions
diff --git a/ext/dom/config.m4 b/ext/dom/config.m4
index 81adf5596..3be333ef6 100644
--- a/ext/dom/config.m4
+++ b/ext/dom/config.m4
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.15 2003/12/07 15:37:30 sniper Exp $
+dnl $Id: config.m4,v 1.15.2.1 2005/04/27 13:13:37 sniper Exp $
dnl
PHP_ARG_ENABLE(dom, whether to enable DOM support,
@@ -10,7 +10,11 @@ if test -z "$PHP_LIBXML_DIR"; then
[ --with-libxml-dir[=DIR] DOM: libxml2 install prefix.], no, no)
fi
-if test "$PHP_DOM" != "no" && test "$PHP_LIBXML" != "no"; then
+if test "$PHP_DOM" != "no"; then
+
+ if test "$PHP_LIBXML" = "no"; then
+ AC_MSG_ERROR([DOM extension requires LIBXML extension, add --enable-libxml])
+ fi
PHP_SETUP_LIBXML(DOM_SHARED_LIBADD, [
AC_DEFINE(HAVE_DOM,1,[ ])
diff --git a/ext/dom/dom_ce.h b/ext/dom/dom_ce.h
index e3b60742a..2d3e93e26 100644
--- a/ext/dom/dom_ce.h
+++ b/ext/dom/dom_ce.h
@@ -17,41 +17,41 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dom_ce.h,v 1.6 2004/01/08 17:32:03 sniper Exp $ */
+/* $Id: dom_ce.h,v 1.6.2.1 2005/06/22 19:58:33 rrichards Exp $ */
#ifndef DOM_CE_H
#define DOM_CE_H
-zend_class_entry *dom_domexception_class_entry;
-zend_class_entry *dom_domstringlist_class_entry;
-zend_class_entry *dom_namelist_class_entry;
-zend_class_entry *dom_domimplementationlist_class_entry;
-zend_class_entry *dom_domimplementationsource_class_entry;
-zend_class_entry *dom_domimplementation_class_entry;
-zend_class_entry *dom_documentfragment_class_entry;
-zend_class_entry *dom_document_class_entry;
-zend_class_entry *dom_nodelist_class_entry;
-zend_class_entry *dom_namednodemap_class_entry;
-zend_class_entry *dom_characterdata_class_entry;
-zend_class_entry *dom_attr_class_entry;
-zend_class_entry *dom_element_class_entry;
-zend_class_entry *dom_text_class_entry;
-zend_class_entry *dom_comment_class_entry;
-zend_class_entry *dom_typeinfo_class_entry;
-zend_class_entry *dom_userdatahandler_class_entry;
-zend_class_entry *dom_domerror_class_entry;
-zend_class_entry *dom_domerrorhandler_class_entry;
-zend_class_entry *dom_domlocator_class_entry;
-zend_class_entry *dom_domconfiguration_class_entry;
-zend_class_entry *dom_cdatasection_class_entry;
-zend_class_entry *dom_documenttype_class_entry;
-zend_class_entry *dom_notation_class_entry;
-zend_class_entry *dom_entity_class_entry;
-zend_class_entry *dom_entityreference_class_entry;
-zend_class_entry *dom_processinginstruction_class_entry;
-zend_class_entry *dom_string_extend_class_entry;
+extern zend_class_entry *dom_domexception_class_entry;
+extern zend_class_entry *dom_domstringlist_class_entry;
+extern zend_class_entry *dom_namelist_class_entry;
+extern zend_class_entry *dom_domimplementationlist_class_entry;
+extern zend_class_entry *dom_domimplementationsource_class_entry;
+extern zend_class_entry *dom_domimplementation_class_entry;
+extern zend_class_entry *dom_documentfragment_class_entry;
+extern zend_class_entry *dom_document_class_entry;
+extern zend_class_entry *dom_nodelist_class_entry;
+extern zend_class_entry *dom_namednodemap_class_entry;
+extern zend_class_entry *dom_characterdata_class_entry;
+extern zend_class_entry *dom_attr_class_entry;
+extern zend_class_entry *dom_element_class_entry;
+extern zend_class_entry *dom_text_class_entry;
+extern zend_class_entry *dom_comment_class_entry;
+extern zend_class_entry *dom_typeinfo_class_entry;
+extern zend_class_entry *dom_userdatahandler_class_entry;
+extern zend_class_entry *dom_domerror_class_entry;
+extern zend_class_entry *dom_domerrorhandler_class_entry;
+extern zend_class_entry *dom_domlocator_class_entry;
+extern zend_class_entry *dom_domconfiguration_class_entry;
+extern zend_class_entry *dom_cdatasection_class_entry;
+extern zend_class_entry *dom_documenttype_class_entry;
+extern zend_class_entry *dom_notation_class_entry;
+extern zend_class_entry *dom_entity_class_entry;
+extern zend_class_entry *dom_entityreference_class_entry;
+extern zend_class_entry *dom_processinginstruction_class_entry;
+extern zend_class_entry *dom_string_extend_class_entry;
#if defined(LIBXML_XPATH_ENABLED)
-zend_class_entry *dom_xpath_class_entry;
+extern zend_class_entry *dom_xpath_class_entry;
#endif
-zend_class_entry *dom_namespace_node_class_entry;
+extern zend_class_entry *dom_namespace_node_class_entry;
#endif /* DOM_CE_H */
diff --git a/ext/dom/element.c b/ext/dom/element.c
index afd8a11ab..3a43a32a7 100644
--- a/ext/dom/element.c
+++ b/ext/dom/element.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: element.c,v 1.30.2.2 2004/11/18 19:55:00 rrichards Exp $ */
+/* $Id: element.c,v 1.30.2.4 2005/05/20 15:02:48 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -250,7 +250,7 @@ PHP_FUNCTION(dom_element_set_attribute)
}
attr = xmlHasProp(nodep,name);
- if (attr != NULL) {
+ if (attr != NULL && attr->type != XML_ATTRIBUTE_DECL) {
node_list_unlink(attr->children TSRMLS_CC);
}
attr = xmlSetProp(nodep, name, value);
@@ -294,13 +294,14 @@ PHP_FUNCTION(dom_element_remove_attribute)
RETURN_FALSE;
}
- /* TODO: DTD defined attributes are handled special */
- if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) {
- node_list_unlink(attrp->children TSRMLS_CC);
- xmlUnlinkNode((xmlNodePtr) attrp);
- xmlFreeProp(attrp);
- } else {
- xmlUnlinkNode((xmlNodePtr) attrp);
+ if (attrp->type != XML_ATTRIBUTE_DECL) {
+ if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) {
+ node_list_unlink(attrp->children TSRMLS_CC);
+ xmlUnlinkNode((xmlNodePtr) attrp);
+ xmlFreeProp(attrp);
+ } else {
+ xmlUnlinkNode((xmlNodePtr) attrp);
+ }
}
RETURN_TRUE;
@@ -368,7 +369,7 @@ PHP_FUNCTION(dom_element_set_attribute_node)
}
existattrp = xmlHasProp(nodep, attrp->name);
- if (existattrp != NULL) {
+ if (existattrp != NULL && existattrp->type != XML_ATTRIBUTE_DECL) {
if ((oldobj = php_dom_object_get_data((xmlNodePtr) existattrp)) != NULL &&
((php_libxml_node_ptr *)oldobj->ptr)->node == (xmlNodePtr) attrp)
{
@@ -540,7 +541,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns)
if (errorcode == 0) {
if (uri_len > 0) {
nodep = (xmlNodePtr) xmlHasNsProp(elemp, localname, uri);
- if (nodep != NULL) {
+ if (nodep != NULL && nodep->type != XML_ATTRIBUTE_DECL) {
node_list_unlink(nodep->children TSRMLS_CC);
}
@@ -578,7 +579,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns)
}
} else {
attr = xmlHasProp(elemp, localname);
- if (attr != NULL) {
+ if (attr != NULL && attr->type != XML_ATTRIBUTE_DECL) {
node_list_unlink(attr->children TSRMLS_CC);
}
attr = xmlSetProp(elemp, localname, value);
@@ -642,7 +643,7 @@ PHP_FUNCTION(dom_element_remove_attribute_ns)
}
}
- if (attrp) {
+ if (attrp && attrp->type != XML_ATTRIBUTE_DECL) {
if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) {
node_list_unlink(attrp->children TSRMLS_CC);
xmlUnlinkNode((xmlNodePtr) attrp);
@@ -726,7 +727,7 @@ PHP_FUNCTION(dom_element_set_attribute_node_ns)
existattrp = xmlHasProp(nodep, attrp->name);
}
- if (existattrp != NULL) {
+ if (existattrp != NULL && existattrp->type != XML_ATTRIBUTE_DECL) {
if ((oldobj = php_dom_object_get_data((xmlNodePtr) existattrp)) != NULL &&
((php_libxml_node_ptr *)oldobj->ptr)->node == (xmlNodePtr) attrp)
{
diff --git a/ext/dom/node.c b/ext/dom/node.c
index b87d181ba..154067db4 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: node.c,v 1.29.2.3 2005/02/18 11:47:50 rrichards Exp $ */
+/* $Id: node.c,v 1.29.2.6 2005/05/20 15:02:48 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -856,7 +856,51 @@ int dom_node_text_content_write(dom_object *obj, zval *newval TSRMLS_DC)
/* }}} */
+static xmlNodePtr _php_dom_insert_fragment(xmlNodePtr nodep, xmlNodePtr prevsib,
+ xmlNodePtr nextsib, xmlNodePtr fragment,
+ dom_object *intern, dom_object *childobj TSRMLS_DC)
+{
+ xmlNodePtr newchild, node;
+
+ newchild = fragment->children;
+
+ if (newchild) {
+ if (prevsib == NULL) {
+ nodep->children = newchild;
+ } else {
+ prevsib->next = newchild;
+ }
+ newchild->prev = prevsib;
+ if (nextsib == NULL) {
+ nodep->last = fragment->last;
+ } else {
+ fragment->last->next = nextsib;
+ nextsib->prev = fragment->last;
+ }
+
+ node = newchild;
+ while (node != NULL) {
+ node->parent = nodep;
+ if (node->doc != nodep->doc) {
+ xmlSetTreeDoc(node, nodep->doc);
+ if (node->_private != NULL) {
+ childobj = node->_private;
+ childobj->document = intern->document;
+ php_libxml_increment_doc_ref((php_libxml_node_object *)childobj, NULL TSRMLS_CC);
+ }
+ }
+ if (node == fragment->last) {
+ break;
+ }
+ node = node->next;
+ }
+ fragment->children = NULL;
+ fragment->last = NULL;
+ }
+
+ return newchild;
+}
/* {{{ proto domnode dom_node_insert_before(DomNode newChild, DomNode refChild);
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-952280727
@@ -948,7 +992,7 @@ PHP_FUNCTION(dom_node_insert_before)
lastattr = xmlHasProp(refp->parent, child->name);
else
lastattr = xmlHasNsProp(refp->parent, child->name, child->ns->href);
- if (lastattr != NULL) {
+ if (lastattr != NULL && lastattr->type != XML_ATTRIBUTE_DECL) {
if (lastattr != (xmlAttrPtr) child) {
xmlUnlinkNode((xmlNodePtr) lastattr);
php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC);
@@ -958,32 +1002,7 @@ PHP_FUNCTION(dom_node_insert_before)
}
}
} else if (child->type == XML_DOCUMENT_FRAG_NODE) {
- xmlNodePtr fragment;
-
- fragment = child;
- new_child = child->children;
- child = new_child;
- while (child->next != NULL) {
- child->parent = parentp;
- if (child->doc != parentp->doc) {
- xmlSetTreeDoc(child, parentp->doc);
- }
- child = child->next;
- }
- child->parent = parentp;
- if (child->doc != parentp->doc) {
- xmlSetTreeDoc(child, parentp->doc);
- }
-
- if (refp->prev != NULL) {
- refp->prev->next = new_child;
- } else {
- parentp->children = new_child;
- }
- new_child->prev = refp->prev;
- refp->prev = child;
- child->next = refp;
- fragment->children = NULL;
+ new_child = _php_dom_insert_fragment(parentp, refp->prev, refp, child, intern, childobj TSRMLS_CC);
}
if (new_child == NULL) {
@@ -1015,7 +1034,7 @@ PHP_FUNCTION(dom_node_insert_before)
lastattr = xmlHasProp(parentp, child->name);
else
lastattr = xmlHasNsProp(parentp, child->name, child->ns->href);
- if (lastattr != NULL) {
+ if (lastattr != NULL && lastattr->type != XML_ATTRIBUTE_DECL) {
if (lastattr != (xmlAttrPtr) child) {
xmlUnlinkNode((xmlNodePtr) lastattr);
php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC);
@@ -1025,32 +1044,7 @@ PHP_FUNCTION(dom_node_insert_before)
}
}
} else if (child->type == XML_DOCUMENT_FRAG_NODE) {
- xmlNodePtr fragment;
-
- fragment = child;
-
- new_child = child->children;
- if (parentp->children == NULL) {
- parentp->children = new_child;
- } else {
- child = parentp->last;
- child->next = new_child;
- new_child->prev = child;
- }
- child = new_child;
- while (child->next != NULL) {
- child->parent = parentp;
- if (child->doc != parentp->doc) {
- xmlSetTreeDoc(child, parentp->doc);
- }
- child = child->next;
- }
- child->parent = parentp;
- if (child->doc != parentp->doc) {
- xmlSetTreeDoc(child, parentp->doc);
- }
- parentp->last = child;
- fragment->children = NULL;
+ new_child = _php_dom_insert_fragment(parentp, parentp->last, NULL, child, intern, childobj TSRMLS_CC);
}
if (new_child == NULL) {
new_child = xmlAddChild(parentp, child);
@@ -1133,50 +1127,16 @@ PHP_FUNCTION(dom_node_replace_child)
zval *rv = NULL;
if (newchild->type == XML_DOCUMENT_FRAG_NODE) {
- xmlNodePtr fragment, prevsib, nextsib;
- fragment = newchild;
+ xmlNodePtr prevsib, nextsib;
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;
+ newchild = _php_dom_insert_fragment(nodep, prevsib, nextsib, newchild, intern, newchildobj TSRMLS_CC);
+ if (newchild) {
+ dom_reconcile_ns(nodep->doc, newchild);
}
-
- fragment->children = NULL;
- fragment->last = NULL;
} else if (oldchild != newchild) {
if (newchild->doc == NULL && nodep->doc != NULL) {
xmlSetTreeDoc(newchild, nodep->doc);
@@ -1326,38 +1286,14 @@ PHP_FUNCTION(dom_node_append_child)
lastattr = xmlHasProp(nodep, child->name);
else
lastattr = xmlHasNsProp(nodep, child->name, child->ns->href);
- if (lastattr != NULL) {
+ if (lastattr != NULL && lastattr->type != XML_ATTRIBUTE_DECL) {
if (lastattr != (xmlAttrPtr) child) {
xmlUnlinkNode((xmlNodePtr) lastattr);
php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC);
}
}
} else if (child->type == XML_DOCUMENT_FRAG_NODE) {
- xmlNodePtr fragment;
-
- fragment = child;
- new_child = child->children;
- if (nodep->children == NULL) {
- nodep->children = new_child;
- } else {
- child = nodep->last;
- child->next = new_child;
- new_child->prev = child;
- }
- child = new_child;
- while (child->next != NULL) {
- child->parent = nodep;
- if (child->doc != nodep->doc) {
- xmlSetTreeDoc(child, nodep->doc);
- }
- child = child->next;
- }
- child->parent = nodep;
- if (child->doc != nodep->doc) {
- xmlSetTreeDoc(child, nodep->doc);
- }
- nodep->last = child;
- fragment->children = NULL;
+ new_child = _php_dom_insert_fragment(nodep, nodep->last, NULL, child, intern, childobj TSRMLS_CC);
}
if (new_child == NULL) {
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 3187a04bd..95a7f7602 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_dom.c,v 1.60.2.6 2005/02/09 11:47:12 rrichards Exp $ */
+/* $Id: php_dom.c,v 1.60.2.8 2005/06/22 19:58:33 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -34,6 +34,40 @@
#define PHP_XPATH 1
#define PHP_XPTR 2
+zend_class_entry *dom_node_class_entry;
+zend_class_entry *dom_domexception_class_entry;
+zend_class_entry *dom_domstringlist_class_entry;
+zend_class_entry *dom_namelist_class_entry;
+zend_class_entry *dom_domimplementationlist_class_entry;
+zend_class_entry *dom_domimplementationsource_class_entry;
+zend_class_entry *dom_domimplementation_class_entry;
+zend_class_entry *dom_documentfragment_class_entry;
+zend_class_entry *dom_document_class_entry;
+zend_class_entry *dom_nodelist_class_entry;
+zend_class_entry *dom_namednodemap_class_entry;
+zend_class_entry *dom_characterdata_class_entry;
+zend_class_entry *dom_attr_class_entry;
+zend_class_entry *dom_element_class_entry;
+zend_class_entry *dom_text_class_entry;
+zend_class_entry *dom_comment_class_entry;
+zend_class_entry *dom_typeinfo_class_entry;
+zend_class_entry *dom_userdatahandler_class_entry;
+zend_class_entry *dom_domerror_class_entry;
+zend_class_entry *dom_domerrorhandler_class_entry;
+zend_class_entry *dom_domlocator_class_entry;
+zend_class_entry *dom_domconfiguration_class_entry;
+zend_class_entry *dom_cdatasection_class_entry;
+zend_class_entry *dom_documenttype_class_entry;
+zend_class_entry *dom_notation_class_entry;
+zend_class_entry *dom_entity_class_entry;
+zend_class_entry *dom_entityreference_class_entry;
+zend_class_entry *dom_processinginstruction_class_entry;
+zend_class_entry *dom_string_extend_class_entry;
+#if defined(LIBXML_XPATH_ENABLED)
+zend_class_entry *dom_xpath_class_entry;
+#endif
+zend_class_entry *dom_namespace_node_class_entry;
+
zend_object_handlers dom_object_handlers;
zend_object_handlers dom_ze1_object_handlers;
@@ -360,6 +394,7 @@ zend_object_value dom_objects_store_clone_obj(zval *zobject TSRMLS_DC)
zend_object_value retval;
void *new_object;
dom_object *intern;
+ dom_object *old_object;
struct _store_object *obj;
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
@@ -376,6 +411,9 @@ zend_object_value dom_objects_store_clone_obj(zval *zobject TSRMLS_DC)
intern->handle = retval.handle;
retval.handlers = Z_OBJ_HT_P(zobject);
+ old_object = (dom_object *) obj->object;
+ zend_objects_clone_members(&intern->std, retval, &old_object->std, intern->handle TSRMLS_CC);
+
return retval;
}
@@ -882,7 +920,7 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml
}
-static dom_object* dom_objects_set_class(zend_class_entry *class_type TSRMLS_DC)
+static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool hash_copy TSRMLS_DC)
{
zend_class_entry *base_class;
zval *tmp;
@@ -905,7 +943,9 @@ static dom_object* dom_objects_set_class(zend_class_entry *class_type TSRMLS_DC)
ALLOC_HASHTABLE(intern->std.properties);
zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
- zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+ if (hash_copy) {
+ zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+ }
return intern;
}
@@ -918,7 +958,7 @@ void dom_objects_clone(void *object, void **object_clone TSRMLS_DC)
xmlNodePtr node;
xmlNodePtr cloned_node;
- clone = dom_objects_set_class(intern->std.ce TSRMLS_CC);
+ clone = dom_objects_set_class(intern->std.ce, 0 TSRMLS_CC);
if (instanceof_function(intern->std.ce, dom_node_class_entry TSRMLS_CC)) {
node = (xmlNodePtr)dom_object_get_node((dom_object *) object);
@@ -946,7 +986,7 @@ zend_object_value dom_objects_new(zend_class_entry *class_type TSRMLS_DC)
zend_object_value retval;
dom_object *intern;
- intern = dom_objects_set_class(class_type TSRMLS_CC);
+ intern = dom_objects_set_class(class_type, 1 TSRMLS_CC);
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t)dom_objects_free_storage, dom_objects_clone TSRMLS_CC);
intern->handle = retval.handle;
@@ -963,7 +1003,7 @@ zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC)
zend_object_value retval;
dom_object *intern;
- intern = dom_objects_set_class(class_type TSRMLS_CC);
+ intern = dom_objects_set_class(class_type, 1 TSRMLS_CC);
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t)dom_xpath_objects_free_storage, dom_objects_clone TSRMLS_CC);
intern->handle = retval.handle;
@@ -1019,7 +1059,7 @@ zend_object_value dom_nnodemap_objects_new(zend_class_entry *class_type TSRMLS_D
dom_object *intern;
dom_nnodemap_object *objmap;
- intern = dom_objects_set_class(class_type TSRMLS_CC);
+ intern = dom_objects_set_class(class_type, 1 TSRMLS_CC);
intern->ptr = emalloc(sizeof(dom_nnodemap_object));
objmap = (dom_nnodemap_object *)intern->ptr;
objmap->baseobj = NULL;
diff --git a/ext/dom/tests/bug32615.phpt b/ext/dom/tests/bug32615.phpt
new file mode 100644
index 000000000..e48973429
--- /dev/null
+++ b/ext/dom/tests/bug32615.phpt
@@ -0,0 +1,84 @@
+--TEST--
+Bug # 32615: (Replacing and inserting Fragments)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new DomDocument;
+$frag = $dom->createDocumentFragment();
+$frag->appendChild(new DOMElement('root'));
+$dom->appendChild($frag);
+$root = $dom->documentElement;
+
+$frag->appendChild(new DOMElement('first'));
+$root->appendChild($frag);
+
+$frag->appendChild(new DOMElement('second'));
+$root->appendChild($frag);
+
+$node = $dom->createElement('newfirst');
+$frag->appendChild($node);
+$root->replaceChild($frag, $root->firstChild);
+
+unset($frag);
+$frag = $dom->createDocumentFragment();
+
+$frag->appendChild(new DOMElement('newsecond'));
+$root->replaceChild($frag, $root->lastChild);
+
+$node = $frag->appendChild(new DOMElement('fourth'));
+$root->insertBefore($frag, NULL);
+
+$frag->appendChild(new DOMElement('third'));
+$node = $root->insertBefore($frag, $node);
+
+$frag->appendChild(new DOMElement('start'));
+$root->insertBefore($frag, $root->firstChild);
+
+$frag->appendChild(new DOMElement('newthird'));
+$root->replaceChild($frag, $node);
+
+$frag->appendChild(new DOMElement('newfourth'));
+$root->replaceChild($frag, $root->lastChild);
+
+$frag->appendChild(new DOMElement('first'));
+$root->replaceChild($frag, $root->firstChild->nextSibling);
+
+$root->removeChild($root->firstChild);
+
+echo $dom->saveXML()."\n";
+
+while ($root->hasChildNodes()) {
+ $root->removeChild($root->firstChild);
+}
+
+$frag->appendChild(new DOMElement('first'));
+$root->insertBefore($frag, $root->firstChild);
+
+$node = $frag->appendChild(new DOMElement('fourth'));
+$root->appendChild($frag);
+
+$frag->appendChild(new DOMElement('second'));
+$frag->appendChild(new DOMElement('third'));
+$root->insertBefore($frag, $node);
+
+echo $dom->saveXML()."\n";
+
+$frag = $dom->createDocumentFragment();
+$root = $dom->documentElement;
+$root->replaceChild($frag, $root->firstChild);
+
+echo $dom->saveXML();
+
+?>
+--EXPECT--
+
+<?xml version="1.0"?>
+<root><first/><newsecond/><newthird/><newfourth/></root>
+
+<?xml version="1.0"?>
+<root><first/><second/><third/><fourth/></root>
+
+<?xml version="1.0"?>
+<root><second/><third/><fourth/></root>
+
diff --git a/ext/dom/tests/dom003.phpt b/ext/dom/tests/dom003.phpt
index e8c1db2ce..3c4e243c4 100644
--- a/ext/dom/tests/dom003.phpt
+++ b/ext/dom/tests/dom003.phpt
@@ -27,11 +27,30 @@ object(DOMException)#%d (6) {
["string:private"]=>
string(0) ""
["file:protected"]=>
- string(%d) "%s/ext/dom/tests/dom003.php"
+ string(%d) "%sdom003.php"
["line:protected"]=>
int(8)
["trace:private"]=>
- array(0) {
+ array(1) {
+ [0]=>
+ array(6) {
+ ["file"]=>
+ string(%d) "%sdom003.php"
+ ["line"]=>
+ int(8)
+ ["function"]=>
+ string(11) "appendChild"
+ ["class"]=>
+ string(7) "DOMNode"
+ ["type"]=>
+ string(2) "->"
+ ["args"]=>
+ array(1) {
+ [0]=>
+ object(DOMElement)#%d (0) {
+ }
+ }
+ }
}
["code"]=>
int(3)
@@ -40,5 +59,6 @@ object(DOMException)#%d (6) {
Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error' in %sdom003.php:%d
Stack trace:
-#0 {main}
+#0 %sdom003.php(%d): DOMNode->appendChild(Object(DOMElement))
+#1 {main}
thrown in %sdom003.php on line %d
diff --git a/ext/dom/xml_common.h b/ext/dom/xml_common.h
index 7c9292b83..eb5b569e1 100644
--- a/ext/dom/xml_common.h
+++ b/ext/dom/xml_common.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xml_common.h,v 1.19 2004/01/08 17:32:03 sniper Exp $ */
+/* $Id: xml_common.h,v 1.19.2.1 2005/06/22 19:58:33 rrichards Exp $ */
#ifndef PHP_XML_COMMON_H
#define PHP_XML_COMMON_H
@@ -54,12 +54,12 @@ typedef struct _dom_object {
#endif /* DOM_EXPORTS */
#endif /* PHP_WIN32 */
-#define PHP_DOM_EXPORT(__type) PHPAPI __type
+#define PHP_DOM_EXPORT PHPAPI
-PHP_DOM_EXPORT(zend_class_entry *) dom_node_class_entry;
-PHP_DOM_EXPORT(dom_object *) php_dom_object_get_data(xmlNodePtr obj);
-PHP_DOM_EXPORT(zval *) php_dom_create_object(xmlNodePtr obj, int *found, zval *in, zval* return_value, dom_object *domobj TSRMLS_DC);
-PHP_DOM_EXPORT(xmlNodePtr) dom_object_get_node(dom_object *obj);
+PHP_DOM_EXPORT extern zend_class_entry *dom_node_class_entry;
+PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj);
+PHP_DOM_EXPORT zval *php_dom_create_object(xmlNodePtr obj, int *found, zval *in, zval* return_value, dom_object *domobj TSRMLS_DC);
+PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
#define DOM_XMLNS_NAMESPACE \
(const xmlChar *) "http://www.w3.org/2000/xmlns/"