1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  Fix accessing of overridden private property in get_object_vars()
This commit is contained in:
Ilija Tovilo
2025-10-20 17:18:29 +02:00
3 changed files with 32 additions and 0 deletions

2
NEWS
View File

@@ -8,6 +8,8 @@ PHP NEWS
. Fixed bug GH-19844 (Don't bail when closing resources on shutdown). (ilutov)
. Fixed deprecation for default case statement followed by semicolon not
being emitted. (theodorejb)
. Fixed bug GH-20177 (Accessing overridden private property in
get_object_vars() triggers assertion error). (ilutov)
- DOM:
. Fix getNamedItemNS() incorrect namespace check. (nielsdos)

25
Zend/tests/gh20177.phpt Normal file
View File

@@ -0,0 +1,25 @@
--TEST--
GH-20177: Access overridden private property in get_object_vars()
--FILE--
<?php
class A {
private $prop = 'A::$prop';
public function __construct() {
var_dump(get_object_vars($this));
}
}
class B extends A {
protected $prop = 'B::$prop';
}
new B;
?>
--EXPECT--
array(1) {
["prop"]=>
string(8) "A::$prop"
}

View File

@@ -566,6 +566,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;