1
0
mirror of https://github.com/php/php-src.git synced 2026-04-02 21:52:36 +02:00

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.
This commit is contained in:
Nikita Popov
2019-01-15 09:53:37 +01:00
parent 6f6532d32b
commit 61d00c0c55
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
--TEST--
Handling of UNDEF property in compound assign
--FILE--
<?php
class C {
public $a = 0;
}
function foo() {
$x = new C;
$x->a = 1;
unset($x->a);
$x->a += 2;
var_dump($x);
}
foo();
?>
--EXPECTF--
Notice: Undefined property: C::$a in %s on line %d
object(C)#1 (1) {
["a"]=>
int(2)
}

View File

@@ -1018,6 +1018,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int typ
if (EXPECTED(!zobj->ce->__get) ||
UNEXPECTED((*zend_get_property_guard(zobj, name)) & IN_GET)) {
if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
ZVAL_NULL(retval);
zend_error(E_NOTICE, "Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
}
} else {