cvs: ZendEngine2 / zend_API.c /tests bug30332.phpt
| From: | Dmitry Stogov | Date: | Fri, 29 Apr 2005 07:59:04 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c /tests bug30332.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-3616@lists.php.net to get a copy of this message | ||
dmitry Fri Apr 29 03:59:04 2005 EDT
Modified files:
/ZendEngine2 zend_API.c
/ZendEngine2/tests bug30332.phpt
Log:
Fixed bug #30332 (zend.ze1_compatibility_mode isnt fully compatable with array_push())
http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.284&r2=1.285&ty=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.284 ZendEngine2/zend_API.c:1.285
--- ZendEngine2/zend_API.c:1.284 Wed Apr 27 11:45:35 2005
+++ ZendEngine2/zend_API.c Fri Apr 29 03:59:03 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.284 2005/04/27 15:45:35 dmitry Exp $ */
+/* $Id: zend_API.c,v 1.285 2005/04/29 07:59:03 dmitry Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -152,7 +152,21 @@
}
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;
http://cvs.php.net/diff.php/ZendEngine2/tests/bug30332.phpt?r1=1.1&r2=1.2&ty=u
Index: ZendEngine2/tests/bug30332.phpt
diff -u /dev/null ZendEngine2/tests/bug30332.phpt:1.2
--- /dev/null Fri Apr 29 03:59:04 2005
+++ ZendEngine2/tests/bug30332.phpt Fri Apr 29 03:59:04 2005
@@ -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
+ (
+ )
+
+)