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

Merge branch 'PHP-8.3' into PHP-8.4

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

2
NEWS
View File

@@ -9,6 +9,8 @@ PHP NEWS
. Fixed bug GH-20085 (Assertion failure when combining lazy object
get_properties exception with foreach loop). (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

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

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