Skip to content

Commit 93288d0

Browse files
committed
Fix bug #68188
1 parent 25e65a7 commit 93288d0

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2014, PHP 5.5.19
44

5+
- Core:
6+
. Fixed bug #68188 ($a->foo .= 'test'; can leave $a->foo undefined). (Nikita)
7+
58

69
?? ??? 2014, PHP 5.5.18
710

Zend/tests/bug68118.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #68118: $a->foo .= 'test'; can leave $a->foo undefined
3+
--FILE--
4+
<?php
5+
6+
set_error_handler(function() {
7+
$obj = new stdClass;
8+
$obj->test = 'meow';
9+
return true;
10+
});
11+
12+
$a = new stdClass;
13+
$a->undefined .= 'test';
14+
var_dump($a);
15+
16+
?>
17+
--EXPECT--
18+
object(stdClass)#2 (1) {
19+
["undefined"]=>
20+
string(4) "test"
21+
}

Zend/zend_object_handlers.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,6 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member, int type
754754
/* we don't have access controls - will just add it */
755755
new_zval = &EG(uninitialized_zval);
756756

757-
if(UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
758-
zend_error(E_NOTICE, "Undefined property: %s::$%s", zobj->ce->name, Z_STRVAL_P(member));
759-
}
760757
Z_ADDREF_P(new_zval);
761758
if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
762759
property_info->offset >= 0) {
@@ -776,6 +773,12 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member, int type
776773
}
777774
zend_hash_quick_update(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, &new_zval, sizeof(zval *), (void **) &retval);
778775
}
776+
777+
/* Notice is thrown after creation of the property, to avoid EG(std_property_info)
778+
* being overwritten in an error handler. */
779+
if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
780+
zend_error(E_NOTICE, "Undefined property: %s::$%s", zobj->ce->name, Z_STRVAL_P(member));
781+
}
779782
} else {
780783
/* we do have getter - fail and let it try again with usual get/set */
781784
retval = NULL;

0 commit comments

Comments
 (0)