summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xZend/tests/bug32660.phpt5
-rwxr-xr-xZend/tests/bug37667.phpt14
-rw-r--r--Zend/zend_object_handlers.c18
3 files changed, 31 insertions, 6 deletions
diff --git a/Zend/tests/bug32660.phpt b/Zend/tests/bug32660.phpt
index f173b287e1..a598954dda 100755
--- a/Zend/tests/bug32660.phpt
+++ b/Zend/tests/bug32660.phpt
@@ -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
diff --git a/Zend/tests/bug37667.phpt b/Zend/tests/bug37667.phpt
index 429a9be3af..b05f296f01 100755
--- a/Zend/tests/bug37667.phpt
+++ b/Zend/tests/bug37667.phpt
@@ -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===
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index d3a52064fe..6b4e00edb3 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -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;
}