]> granicus.if.org Git - php/commitdiff
Changed error message (E_ERROR -> E_NOTICE) in case of indirect modification of overl...
authorDmitry Stogov <dmitry@php.net>
Fri, 21 Jul 2006 10:32:17 +0000 (10:32 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 21 Jul 2006 10:32:17 +0000 (10:32 +0000)
Zend/tests/bug32660.phpt
Zend/tests/bug37667.phpt
Zend/zend_object_handlers.c

index f173b287e1b62a434e121d8b2921d83f1c9b0ba7..a598954dda8294a3dce4f667a33b69ebf60d202d 100755 (executable)
@@ -28,9 +28,12 @@ $b = "much longer";
 print_r($a);
 ?>
 --EXPECTF--
+Notice: Indirect modification of overloaded property A::$whatever has no effect in %sbug32660.php on line 20
 A Object
 (
-    [q] => long
+    [q] => 3
 )
 
+Notice: Indirect modification of overloaded property A::$whatever has no effect in %sbug32660.php on line 23
+
 Fatal error: Cannot assign by reference to overloaded object in %sbug32660.php on line 23
index 429a9be3afb7729fdf185290e19964ae943a7a70..b05f296f010bd5481b1affa878115593be27d7bb 100755 (executable)
@@ -30,7 +30,7 @@ var_dump($obj);
 --EXPECTF--
 string(3) "bar"
 
-Notice: Undefined offset:  2 in %sbug37667.php on line %d
+Notice: Undefined offset:  2 in %sbug37667.php on line 16
 NULL
 object(Test)#%d (1) {
   ["property:protected"]=>
@@ -40,4 +40,14 @@ object(Test)#%d (1) {
   }
 }
 
-Fatal error: Cannot use array returned from Test::__get('property') in write context in %sbug37667.php on line %d
+Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 20
+
+Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 21
+object(Test)#%d (1) {
+  ["property:protected"]=>
+  array(1) {
+    ["foo"]=>
+    string(3) "bar"
+  }
+}
+===DONE===
index d3a52064fe716c5723ac0a4431162b0ae3b91ec9..6b4e00edb32480b4dc4bdd5e59ec05cd0c36fadc 100644 (file)
@@ -334,6 +334,18 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC)
 
                        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 (Z_TYPE_P(rv) != IS_OBJECT) {
+                                               zend_error(E_NOTICE, "Indirect modification of overloaded property %s::$%s has no effect", zobj->ce->name, Z_STRVAL_P(member));
+                                       }
+                               }
                        } else {
                                retval = &EG(uninitialized_zval_ptr);
                        }
@@ -349,9 +361,9 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC)
                zval_ptr_dtor(&tmp_member);
                (*retval)->refcount--;
        }
-       if (*retval && (type == BP_VAR_W || type == BP_VAR_RW) && Z_TYPE_PP(retval) == IS_ARRAY) {
-               zend_error(E_ERROR, "Cannot use array returned from %s::__get('%s') in write context", zobj->ce->name, Z_STRVAL_P(member));
-       }
+//     if (*retval && (type == BP_VAR_W || type == BP_VAR_RW) && Z_TYPE_PP(retval) == IS_ARRAY) {
+//             zend_error(E_ERROR, "Cannot use array returned from %s::__get('%s') in write context", zobj->ce->name, Z_STRVAL_P(member));
+//     }
        return *retval;
 }