diff options
| author | Marcus Boerger <helly@php.net> | 2003-07-02 07:24:11 +0000 | 
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2003-07-02 07:24:11 +0000 | 
| commit | 74a0f6c8ab58ec3fb7e3b03f224d88adc94f49d8 (patch) | |
| tree | 95a04d8c427096904d1cf81cdb0a5db0c23c7187 /Zend | |
| parent | 43e74fc8b1c2697135854531bb6e10adfe8c33c4 (diff) | |
| download | php-git-74a0f6c8ab58ec3fb7e3b03f224d88adc94f49d8.tar.gz | |
Finally fix property cloning and fix the tests accordingly.
# The default behaviour is to copy all properties with all current values
# from the old object. But if __clone is overwritten then only the default
# properties are cloned with their correct default values. So we keep
# the type system intact and also allow real __clone overwriting now.
Diffstat (limited to 'Zend')
| -rw-r--r-- | Zend/zend_objects.c | 8 | 
1 files changed, 7 insertions, 1 deletions
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 870ebd5133..4d3398dc37 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -108,12 +108,13 @@ ZEND_API zend_object_value zend_objects_clone_obj(zval *zobject TSRMLS_DC)  	zend_object *new_object;  	zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); +	/* assume that create isn't overwritten, so when clone depends on the  +	 * overwritten one then it must itself be overwritten */  	old_object = zend_objects_get_address(zobject TSRMLS_CC);  	retval = zend_objects_new(&new_object, old_object->ce TSRMLS_CC);  	ALLOC_HASHTABLE(new_object->properties);  	zend_hash_init(new_object->properties, 0, NULL, ZVAL_PTR_DTOR, 0); -	zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, sizeof(zval *));  	if (old_object->ce->clone) {  		zval *old_obj; @@ -121,6 +122,9 @@ ZEND_API zend_object_value zend_objects_clone_obj(zval *zobject TSRMLS_DC)  		zval *clone_func_name;  		zval *retval_ptr;  		HashTable symbol_table; +		zend_class_entry *ce = old_object->ce; + +		zend_hash_copy(new_object->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));  		MAKE_STD_ZVAL(new_obj);  		new_obj->type = IS_OBJECT; @@ -148,6 +152,8 @@ ZEND_API zend_object_value zend_objects_clone_obj(zval *zobject TSRMLS_DC)  		zval_ptr_dtor(&new_obj);  		zval_ptr_dtor(&clone_func_name);  		zval_ptr_dtor(&retval_ptr); +	} else { +		zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, sizeof(zval *));  	}  	return retval;  | 
