summaryrefslogtreecommitdiff
path: root/Zend/zend_objects.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2004-02-02 12:28:19 +0000
committerZeev Suraski <zeev@php.net>2004-02-02 12:28:19 +0000
commit8e30d96ad895442d77d3a7c93cd70a052a257427 (patch)
treebc950bc1a461a35ebf3215f3b3159569568d8e4f /Zend/zend_objects.c
parentc7699856fc7918604943d5f10a9191fdd8f1d21b (diff)
downloadphp-git-8e30d96ad895442d77d3a7c93cd70a052a257427.tar.gz
Redesign the clone() feature to fix some fundamental flaws in the previous
implementation. Using clone directly is now done using $replica = clone $src; Clone methods must now be declared as follows: function __clone($that) { } Clone methods in derived classes can call the __clone method of their parent classes using parent::__clone($that)
Diffstat (limited to 'Zend/zend_objects.c')
-rw-r--r--Zend/zend_objects.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index 05595e84e9..5488511c5c 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -108,6 +108,7 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object_va
zval *retval_ptr;
HashTable symbol_table;
zend_class_entry *ce = old_object->ce;
+ zval **args[1];
zend_hash_copy(new_object->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
@@ -129,9 +130,11 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object_va
clone_func_name->value.str.len = sizeof("__clone")-1;
ZEND_INIT_SYMTABLE(&symbol_table);
- ZEND_SET_SYMBOL(&symbol_table, "that", old_obj);
+ args[0] = &old_obj;
- call_user_function_ex(NULL, &new_obj, clone_func_name, &retval_ptr, 0, NULL, 0, &symbol_table TSRMLS_CC);
+ call_user_function_ex(NULL, &new_obj, clone_func_name, &retval_ptr, 1, args, 1, &symbol_table TSRMLS_CC);
+
+ zval_ptr_dtor(args[0]);
zend_hash_destroy(&symbol_table);
zval_ptr_dtor(&new_obj);