Fix bug #32930 (class extending DOMDocument doesn't clone properly)

This commit is contained in:
Rob Richards 2005-05-03 22:55:03 +00:00
parent bdbce01588
commit 6d2fd215e9

View File

@ -361,6 +361,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);
@ -377,6 +378,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;
}
@ -885,7 +889,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;
@ -908,7 +912,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);
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;
}
@ -921,7 +927,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);
@ -949,7 +955,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;
@ -966,7 +972,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;
@ -1022,7 +1028,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;