]> granicus.if.org Git - php/commitdiff
Fixed bug #34767 (Zend Engine 1 Compatibility not copying objects correctly)
authorDmitry Stogov <dmitry@php.net>
Thu, 20 Oct 2005 08:15:13 +0000 (08:15 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 20 Oct 2005 08:15:13 +0000 (08:15 +0000)
Zend/tests/bug34767.phpt [new file with mode: 0755]
Zend/zend_execute_API.c

diff --git a/Zend/tests/bug34767.phpt b/Zend/tests/bug34767.phpt
new file mode 100755 (executable)
index 0000000..45af9f9
--- /dev/null
@@ -0,0 +1,33 @@
+--TEST--
+Bug #34767 (Zend Engine 1 Compatibility not copying objects correctly)
+--INI--
+zend.ze1_compatibility_mode=1
+error_reporting=4095
+--FILE--
+<?php
+$a->y = &new stdClass();
+print_r($a);
+$b = $a;
+$a->y->z = 1;
+print_r($b);
+?>
+--EXPECTF--
+
+Strict Standards: Assigning the return value of new by reference is deprecated in %sbug34767.php on line 2
+stdClass Object
+(
+    [y] => stdClass Object
+        (
+        )
+
+)
+
+Strict Standards: Implicit cloning object of class 'stdClass' because of 'zend.ze1_compatibility_mode' in %sbug34767.php on line 4
+stdClass Object
+(
+    [y] => stdClass Object
+        (
+            [z] => 1
+        )
+
+)
index 99bf1c2d1b851b77c5783946b354e981ff10b2a8..6273df031f529c4853000bfe69357f0282188ba6 100644 (file)
@@ -396,6 +396,13 @@ ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC)
                zval_dtor(*zval_ptr);
                safe_free_zval_ptr_rel(*zval_ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC);
        } else if ((*zval_ptr)->refcount == 1) {
+               if ((*zval_ptr)->type == IS_OBJECT) {
+                       TSRMLS_FETCH();
+
+                       if (EG(ze1_compatibility_mode)) {
+                               return;
+                       }
+               }
                (*zval_ptr)->is_ref = 0;
        }
 }