]> granicus.if.org Git - php/commitdiff
Fixed bug #30332 (zend.ze1_compatibility_mode isnt fully compatable with array_push())
authorDmitry Stogov <dmitry@php.net>
Fri, 29 Apr 2005 07:58:50 +0000 (07:58 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 29 Apr 2005 07:58:50 +0000 (07:58 +0000)
NEWS
Zend/tests/bug30332.phpt [new file with mode: 0644]
Zend/zend_API.c

diff --git a/NEWS b/NEWS
index 26a2db078148c00b1b818fc3ac89cb6b734c724f..9a6789185191ef8ce3512e9785dd910387deaee2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,8 @@ PHP                                                                        NEWS
 - Fixed bug #30819 (Better support for LDAP SASL bind). (Jani)
 - Fixed bug #30702 (cannot initialize class variable from class constant).
   (Dmitry)
+- Fixed bug #30332 (zend.ze1_compatibility_mode isnt fully compatable with
+  array_push()). (Dmitry)
 - Fixed bug #29944 (Function defined in switch, crashes). (Dmitry)
 - Fixed bug #29583 (crash when echoing a COM object). (M.Sisolak, Wez)
 - Fixed bug #29210 (Function: is_callable - no support for private and
diff --git a/Zend/tests/bug30332.phpt b/Zend/tests/bug30332.phpt
new file mode 100644 (file)
index 0000000..83e78e2
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Bug #30332 (zend.ze1_compatibility_mode isnt fully compatable with array_push())
+--INI--
+zend.ze1_compatibility_mode=on
+--FILE--
+<?php
+class x { };
+
+$first = new x;
+$second = $first;
+$container = array();
+array_push($container, $first);
+
+$first->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
+        (
+        )
+
+)
index 72666cf03ab0faf039f51937f252917c8c38962d..de5b877d3d142e9c605400a10c40e5576081552e 100644 (file)
@@ -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;