From 8b7a03c889a703c5fbb79e66817ab959b562d6a4 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 29 Apr 2005 07:59:04 +0000 Subject: [PATCH] Fixed bug #30332 (zend.ze1_compatibility_mode isnt fully compatable with array_push()) --- Zend/tests/bug30332.phpt | 39 +++++++++++++++++++++++++++++++++++++++ Zend/zend_API.c | 16 +++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/bug30332.phpt diff --git a/Zend/tests/bug30332.phpt b/Zend/tests/bug30332.phpt new file mode 100644 index 0000000000..83e78e29bb --- /dev/null +++ b/Zend/tests/bug30332.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #30332 (zend.ze1_compatibility_mode isnt fully compatable with array_push()) +--INI-- +zend.ze1_compatibility_mode=on +--FILE-- +first = " im in the first"; + +print_r($first); +print_r($second); +print_r($container); +?> +--EXPECTF-- +Strict Standards: Implicit cloning object of class 'x' because of 'zend.ze1_compatibility_mode' in %sbug30332.php on line 4 + +Strict Standards: Implicit cloning object of class 'x' because of 'zend.ze1_compatibility_mode' in %sbug30332.php on line 5 + +Strict Standards: Implicit cloning object of class 'x' because of 'zend.ze1_compatibility_mode' in %sbug30332.php on line 7 +x Object +( + [first] => im in the first +) +x Object +( +) +Array +( + [0] => x Object + ( + ) + +) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 16a9648af1..dac58559d8 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -152,7 +152,21 @@ ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_arr } while (param_count-->0) { - *(argument_array++) = (zval **) p-(arg_count--); + zval **value = (zval**)(p-arg_count); + + if (EG(ze1_compatibility_mode) && Z_TYPE_PP(value) == IS_OBJECT) { + zval *value_ptr; + + ALLOC_ZVAL(value_ptr); + *value_ptr = **value; + INIT_PZVAL(value_ptr); + zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_PP(value)->name); + value_ptr->value.obj = Z_OBJ_HANDLER_PP(value, clone_obj)(*value TSRMLS_CC); + zval_ptr_dtor(value); + *value = value_ptr; + } + *(argument_array++) = value; + arg_count--; } return SUCCESS; -- 2.40.0