dmitry          Fri Dec  8 16:23:05 2006 UTC

  Modified files:              
    /ZendEngine2        zend_execute.c zend_object_handlers.c 
    /ZendEngine2/tests  bug39775.phpt bug38146.phpt 
    /php-src/tests/classes      array_access_003.phpt array_access_004.phpt 
                                array_access_005.phpt array_access_008.phpt 
                                array_access_012.phpt 
    /php-src/ext/spl/tests      iterator_035.phpt 
  Log:
  Fixed bug #39775 ("Indirect modification ..." message is not shown)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?r1=1.753&r2=1.754&diff_format=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.753 ZendEngine2/zend_execute.c:1.754
--- ZendEngine2/zend_execute.c:1.753    Tue Nov  7 20:28:40 2006
+++ ZendEngine2/zend_execute.c  Fri Dec  8 16:23:04 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.c,v 1.753 2006/11/07 20:28:40 iliaa Exp $ */
+/* $Id: zend_execute.c,v 1.754 2006/12/08 16:23:04 dmitry Exp $ */
 
 #define ZEND_INTENSIVE_DEBUGGING 0
 
@@ -1166,16 +1166,21 @@
                                overloaded_result = 
Z_OBJ_HT_P(container)->read_dimension(container, dim, type TSRMLS_CC);
 
                                if (overloaded_result) {
-                                       switch (type) {
-                                               case BP_VAR_RW:
-                                               case BP_VAR_W:
-                                                       if 
(Z_TYPE_P(overloaded_result) != IS_OBJECT
-                                                               && 
!overloaded_result->is_ref) {
-                                                               
zend_error_noreturn(E_ERROR, "Objects used as arrays in post/pre 
increment/decrement must return values by reference");
-                                                       }
-                                                       break;
+                                       if (type == BP_VAR_W || type == 
BP_VAR_RW  || type == BP_VAR_UNSET) {
+                                               if (overloaded_result->refcount 
> 0) {
+                                                       zval *tmp = 
overloaded_result;
+
+                                                       
ALLOC_ZVAL(overloaded_result);
+                                                       *overloaded_result = 
*tmp;
+                                                       
zval_copy_ctor(overloaded_result);
+                                                       
overloaded_result->is_ref = 0;
+                                                       
overloaded_result->refcount = 0;
+                                               }
+                                               if (Z_TYPE_P(overloaded_result) 
!= IS_OBJECT) {
+                                                       zend_class_entry *ce = 
Z_OBJCE_P(container);
+                                                       zend_error(E_NOTICE, 
"Indirect modification of overloaded element of %v has no effect", ce->name);
+                                               }
                                        }
-
                                        retval = &overloaded_result;
                                } else {
                                        retval = &EG(error_zval_ptr);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.179&r2=1.180&diff_format=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.179 
ZendEngine2/zend_object_handlers.c:1.180
--- ZendEngine2/zend_object_handlers.c:1.179    Fri Nov 10 14:21:13 2006
+++ ZendEngine2/zend_object_handlers.c  Fri Dec  8 16:23:04 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_object_handlers.c,v 1.179 2006/11/10 14:21:13 dmitry Exp $ */
+/* $Id: zend_object_handlers.c,v 1.180 2006/12/08 16:23:04 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_globals.h"
@@ -342,14 +342,16 @@
 
                        if (rv) {
                                retval = &rv;
-                               if ((type == BP_VAR_W || type == BP_VAR_RW  || 
type == BP_VAR_UNSET) && rv->refcount > 0) {
-                                       zval *tmp = rv;
-
-                                       ALLOC_ZVAL(rv);
-                                       *rv = *tmp;
-                                       zval_copy_ctor(rv);
-                                       rv->is_ref = 0;
-                                       rv->refcount = 0;
+                               if (type == BP_VAR_W || type == BP_VAR_RW  || 
type == BP_VAR_UNSET) {
+                                       if (rv->refcount > 0) {
+                                               zval *tmp = rv;
+
+                                               ALLOC_ZVAL(rv);
+                                               *rv = *tmp;
+                                               zval_copy_ctor(rv);
+                                               rv->is_ref = 0;
+                                               rv->refcount = 0;
+                                       }
                                        if (Z_TYPE_P(rv) != IS_OBJECT) {
                                                zend_error(E_NOTICE, "Indirect 
modification of overloaded property %v::$%R has no effect", zobj->ce->name, 
Z_TYPE_P(member), Z_UNIVAL_P(member));
                                        }
@@ -477,19 +479,6 @@
                /* Undo PZVAL_LOCK() */
                retval->refcount--;
 
-               if ((type == BP_VAR_W || type == BP_VAR_RW  || type == 
BP_VAR_UNSET) && retval->refcount > 0) {
-                       zval *tmp = retval;
-
-                       ALLOC_ZVAL(retval);
-                       *retval = *tmp;
-                       zval_copy_ctor(retval);
-                       retval->is_ref = 0;
-                       retval->refcount = 0;
-                       if (Z_TYPE_P(retval) != IS_OBJECT) {
-                               zend_error(E_NOTICE, "Indirect modification of 
overloaded element of %v has no effect", ce->name);
-                       }
-               }
-
                return retval;
        } else {
                zend_error(E_ERROR, "Cannot use object of type %v as array", 
ce->name);
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug39775.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug39775.phpt
diff -u /dev/null ZendEngine2/tests/bug39775.phpt:1.2
--- /dev/null   Fri Dec  8 16:23:05 2006
+++ ZendEngine2/tests/bug39775.phpt     Fri Dec  8 16:23:04 2006
@@ -0,0 +1,20 @@
+--TEST--
+Bug #39775 ("Indirect modification ..." message is not shown)
+--FILE--
+<?php
+class test {
+       var $array = array();
+       function __get($var) {
+               $v =& $this->array;
+               return $this->array;
+       }
+}
+$t = new test;
+$t->anything[] = 'bar';
+print_r($t->anything);
+?>
+--EXPECTF--
+Notice: Indirect modification of overloaded property test::$anything has no 
effect in %sbug39775.php on line 10
+Array
+(
+)
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug38146.phpt?r1=1.2&r2=1.3&diff_format=u
Index: ZendEngine2/tests/bug38146.phpt
diff -u ZendEngine2/tests/bug38146.phpt:1.2 ZendEngine2/tests/bug38146.phpt:1.3
--- ZendEngine2/tests/bug38146.phpt:1.2 Mon Jul 24 07:44:06 2006
+++ ZendEngine2/tests/bug38146.phpt     Fri Dec  8 16:23:04 2006
@@ -14,6 +14,7 @@
     print "$key => $value\n";
 }
 ?>
---EXPECT--
+--EXPECTF--
+Notice: Indirect modification of overloaded property foo::$bar has no effect 
in %sbug38146.php on line 10
 foo => bar
 bar => foo
http://cvs.php.net/viewvc.cgi/php-src/tests/classes/array_access_003.phpt?r1=1.8&r2=1.9&diff_format=u
Index: php-src/tests/classes/array_access_003.phpt
diff -u php-src/tests/classes/array_access_003.phpt:1.8 
php-src/tests/classes/array_access_003.phpt:1.9
--- php-src/tests/classes/array_access_003.phpt:1.8     Thu Sep 15 16:19:48 2005
+++ php-src/tests/classes/array_access_003.phpt Fri Dec  8 16:23:04 2006
@@ -53,7 +53,10 @@
 int(1)
 object::offsetGet(2)
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_003.php on line %d
+Notice: Indirect modification of overloaded element of object has no effect in 
%sarray_access_003.php on line 39
+object::offsetGet(2)
+int(1)
+===DONE===
 --UEXPECTF--
 object::offsetGet(1)
 unicode(6) "fooBar"
@@ -61,4 +64,7 @@
 int(1)
 object::offsetGet(2)
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_003.php on line %d
+Notice: Indirect modification of overloaded element of object has no effect in 
%sarray_access_003.php on line 39
+object::offsetGet(2)
+int(1)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/tests/classes/array_access_004.phpt?r1=1.4&r2=1.5&diff_format=u
Index: php-src/tests/classes/array_access_004.phpt
diff -u php-src/tests/classes/array_access_004.phpt:1.4 
php-src/tests/classes/array_access_004.phpt:1.5
--- php-src/tests/classes/array_access_004.phpt:1.4     Mon Aug 15 14:37:54 2005
+++ php-src/tests/classes/array_access_004.phpt Fri Dec  8 16:23:04 2006
@@ -51,7 +51,10 @@
 int(1)
 object::offsetGet(2)
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_004.php on line %d
+Notice: Indirect modification of overloaded element of object has no effect in 
%sarray_access_004.php on line 39
+object::offsetGet(2)
+int(1)
+===DONE===
 --UEXPECTF--
 object::offsetGet(1)
 unicode(6) "fooBar"
@@ -59,4 +62,7 @@
 int(1)
 object::offsetGet(2)
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_004.php on line %d
+Notice: Indirect modification of overloaded element of object has no effect in 
%sarray_access_004.php on line 39
+object::offsetGet(2)
+int(1)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/tests/classes/array_access_005.phpt?r1=1.7&r2=1.8&diff_format=u
Index: php-src/tests/classes/array_access_005.phpt
diff -u php-src/tests/classes/array_access_005.phpt:1.7 
php-src/tests/classes/array_access_005.phpt:1.8
--- php-src/tests/classes/array_access_005.phpt:1.7     Fri Nov 10 17:34:26 2006
+++ php-src/tests/classes/array_access_005.phpt Fri Dec  8 16:23:04 2006
@@ -70,8 +70,11 @@
 }
 
 Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_005.php on line 46
+string(6) "JoeFoo"
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_005.php on line %d
+Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_005.php on line 48
+string(6) "JoeFoo"
+===DONE===
 --UEXPECTF--
 unicode(3) "Joe"
 unicode(6) "JoeFoo"
@@ -89,5 +92,8 @@
 }
 
 Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_005.php on line 46
+unicode(6) "JoeFoo"
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_005.php on line %d
+Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_005.php on line 48
+unicode(6) "JoeFoo"
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/tests/classes/array_access_008.phpt?r1=1.5&r2=1.6&diff_format=u
Index: php-src/tests/classes/array_access_008.phpt
diff -u php-src/tests/classes/array_access_008.phpt:1.5 
php-src/tests/classes/array_access_008.phpt:1.6
--- php-src/tests/classes/array_access_008.phpt:1.5     Fri Nov 10 17:34:26 2006
+++ php-src/tests/classes/array_access_008.phpt Fri Dec  8 16:23:04 2006
@@ -57,8 +57,14 @@
 string(3) "Foo"
 
 Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_008.php on line 40
+string(3) "Foo"
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_008.php on line %d
+Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_008.php on line 42
+string(3) "Foo"
+
+Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_008.php on line 44
+string(3) "Foo"
+===DONE===
 --UEXPECTF--
 unicode(3) "Foo"
 unicode(6) "FooBar"
@@ -67,5 +73,11 @@
 unicode(3) "Foo"
 
 Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_008.php on line 40
+unicode(3) "Foo"
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_008.php on line %d
+Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_008.php on line 42
+unicode(3) "Foo"
+
+Notice: Indirect modification of overloaded element of Peoples has no effect 
in %sarray_access_008.php on line 44
+unicode(3) "Foo"
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/tests/classes/array_access_012.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/tests/classes/array_access_012.phpt
diff -u php-src/tests/classes/array_access_012.phpt:1.3 
php-src/tests/classes/array_access_012.phpt:1.4
--- php-src/tests/classes/array_access_012.phpt:1.3     Fri Nov 10 17:34:26 2006
+++ php-src/tests/classes/array_access_012.phpt Fri Dec  8 16:23:04 2006
@@ -33,4 +33,4 @@
 
 Notice: Indirect modification of overloaded element of ArrayAccessImpl has no 
effect in %sarray_access_012.php on line 24
 
-Fatal error: Objects used as arrays in post/pre increment/decrement must 
return values by reference in %sarray_access_012.php on line %d
+Fatal error: Cannot assign by reference to overloaded object in 
%sarray_access_012.php on line 24
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_035.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/spl/tests/iterator_035.phpt
diff -u php-src/ext/spl/tests/iterator_035.phpt:1.3 
php-src/ext/spl/tests/iterator_035.phpt:1.4
--- php-src/ext/spl/tests/iterator_035.phpt:1.3 Thu Oct 19 22:30:55 2006
+++ php-src/ext/spl/tests/iterator_035.phpt     Fri Dec  8 16:23:04 2006
@@ -14,4 +14,6 @@
 echo "Done\n";
 ?>
 --EXPECTF--    
+Notice: Indirect modification of overloaded element of ArrayIterator has no 
effect in %siterator_035.php on line 7
+
 Fatal error: Cannot assign by reference to overloaded object in %s on line %d

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to