From 61d00c0c55ebbc2fa59af35befd2f61a80571675 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 15 Jan 2019 09:53:37 +0100 Subject: [PATCH] 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. --- .../typed_properties_103.phpt | 22 +++++++++++++++++++ Zend/zend_object_handlers.c | 1 + 2 files changed, 23 insertions(+) create mode 100644 Zend/tests/type_declarations/typed_properties_103.phpt diff --git a/Zend/tests/type_declarations/typed_properties_103.phpt b/Zend/tests/type_declarations/typed_properties_103.phpt new file mode 100644 index 0000000000..5c0fc85a99 --- /dev/null +++ b/Zend/tests/type_declarations/typed_properties_103.phpt @@ -0,0 +1,22 @@ +--TEST-- +Handling of UNDEF property in compound assign +--FILE-- +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) +} diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index e91202669b..e1e1ff6284 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -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 { -- 2.50.1