diff --git a/NEWS b/NEWS index 4b2a4777fef..3bc4e05761f 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS . Fixed bug GH-20073 (Assertion failure in WeakMap offset operations on reference). (nielsdos) . Fixed bug GH-19844 (Don't bail when closing resources on shutdown). (ilutov) + . Fixed bug GH-20177 (Accessing overridden private property in + get_object_vars() triggers assertion error). (ilutov) - DOM: . Partially fixed bug GH-16317 (DOM classes do not allow diff --git a/Zend/tests/gh20177.phpt b/Zend/tests/gh20177.phpt new file mode 100644 index 00000000000..fd69460067f --- /dev/null +++ b/Zend/tests/gh20177.phpt @@ -0,0 +1,25 @@ +--TEST-- +GH-20177: Access overridden private property in get_object_vars() +--FILE-- + +--EXPECT-- +array(1) { + ["prop"]=> + string(8) "A::$prop" +} diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 2eacb614f97..2fe02e22241 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -528,6 +528,11 @@ ZEND_API zend_result zend_check_property_access(const zend_object *zobj, zend_st return FAILURE; } } else { + /* We were looking for a protected property but found a private one + * belonging to the parent class. */ + if (property_info->flags & ZEND_ACC_PRIVATE) { + return FAILURE; + } ZEND_ASSERT(property_info->flags & ZEND_ACC_PROTECTED); } return SUCCESS;