From 0a853d04f30b96bb90765992426c10fd3ae5f5d8 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Sun, 24 Sep 2006 22:27:20 +0000 Subject: [PATCH] - #38943, properties in extended class cannot be set - use zend_object_std_init instead of a manual initialisation --- ext/zip/php_zip.c | 5 +--- ext/zip/tests/38943.phpt | 50 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 ext/zip/tests/38943.phpt diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 1caa6cdaa6..f4eff31634 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -506,7 +506,6 @@ PHP_ZIP_API zend_object_value php_zip_object_new(zend_class_entry *class_type TS intern = emalloc(sizeof(ze_zip_object)); memset(&intern->zo, 0, sizeof(zend_object)); - intern->zo.ce = class_type; intern->za = NULL; intern->buffers = NULL; @@ -514,8 +513,7 @@ PHP_ZIP_API zend_object_value php_zip_object_new(zend_class_entry *class_type TS intern->buffers_cnt = 0; intern->prop_handler = &zip_prop_handlers; - ALLOC_HASHTABLE(intern->zo.properties); - zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_object_std_init(&intern->zo, class_type TSRMLS_CC); zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); @@ -1870,7 +1868,6 @@ PHP_MINIT_FUNCTION(zip) memcpy(&zip_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); zip_object_handlers.clone_obj = NULL; zip_object_handlers.get_property_ptr_ptr = php_zip_get_property_ptr_ptr; - zip_object_handlers.write_property = NULL; zip_object_handlers.get_properties = php_zip_get_properties; zip_object_handlers.read_property = php_zip_read_property; diff --git a/ext/zip/tests/38943.phpt b/ext/zip/tests/38943.phpt new file mode 100644 index 0000000000..d7236e314b --- /dev/null +++ b/ext/zip/tests/38943.phpt @@ -0,0 +1,50 @@ +--TEST-- +#38943, properties in extended class cannot be set +--SKIPIF-- + +--FILE-- +testarray[] = 1; + var_dump($this->testarray); + } +} + +$z = new myZip; +$z->testp = "foobar"; +var_dump($z); +?> +--EXPECTF-- +array(1) { + [0]=> + int(1) +} +object(myZip)#1 (%d) { + ["test:private"]=> + int(0) + ["testp"]=> + string(6) "foobar" + ["testarray:private"]=> + array(1) { + [0]=> + int(1) + } + ["status"]=> + int(0) + ["statusSys"]=> + int(0) + ["numFiles"]=> + int(0) + ["filename"]=> + string(0) "" + ["comment"]=> + string(0) "" +} -- 2.50.1