Skip to content

Commit 61d00c0

Browse files
committed
Fix handling of UNDEF properties in compound assign
Restore NULLing of UNDEF values in get_property_ptr_ptr for the BP_VAR_R and BP_VAR_RW cases.
1 parent 6f6532d commit 61d00c0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Handling of UNDEF property in compound assign
3+
--FILE--
4+
<?php
5+
class C {
6+
public $a = 0;
7+
}
8+
function foo() {
9+
$x = new C;
10+
$x->a = 1;
11+
unset($x->a);
12+
$x->a += 2;
13+
var_dump($x);
14+
}
15+
foo();
16+
?>
17+
--EXPECTF--
18+
Notice: Undefined property: C::$a in %s on line %d
19+
object(C)#1 (1) {
20+
["a"]=>
21+
int(2)
22+
}

Zend/zend_object_handlers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int typ
10181018
if (EXPECTED(!zobj->ce->__get) ||
10191019
UNEXPECTED((*zend_get_property_guard(zobj, name)) & IN_GET)) {
10201020
if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
1021+
ZVAL_NULL(retval);
10211022
zend_error(E_NOTICE, "Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
10221023
}
10231024
} else {

0 commit comments

Comments
 (0)