mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix prop info fetching from prop slot with added hooks
This commit is contained in:
commit
aa0c54dade
3 changed files with 26 additions and 1 deletions
23
Zend/tests/property_hooks/gh18268.phpt
Normal file
23
Zend/tests/property_hooks/gh18268.phpt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
--TEST--
|
||||||
|
GH-18268: array_walk() on object with added property hooks
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class A {
|
||||||
|
public $prop = 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
class B extends A {
|
||||||
|
public $prop = 42 {
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$b = new B;
|
||||||
|
array_walk($b, function (&$item) {
|
||||||
|
var_dump($item);
|
||||||
|
});
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
int(42)
|
|
@ -467,6 +467,8 @@ typedef struct _zend_property_info {
|
||||||
((uint32_t)(XtOffsetOf(zend_object, properties_table) + sizeof(zval) * (num)))
|
((uint32_t)(XtOffsetOf(zend_object, properties_table) + sizeof(zval) * (num)))
|
||||||
#define OBJ_PROP_TO_NUM(offset) \
|
#define OBJ_PROP_TO_NUM(offset) \
|
||||||
(((offset) - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval))
|
(((offset) - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval))
|
||||||
|
#define OBJ_PROP_SLOT_TO_OFFSET(obj, slot) \
|
||||||
|
((uintptr_t)(slot) - (uintptr_t)(obj))
|
||||||
|
|
||||||
typedef struct _zend_class_constant {
|
typedef struct _zend_class_constant {
|
||||||
zval value; /* flags are stored in u2 */
|
zval value; /* flags are stored in u2 */
|
||||||
|
|
|
@ -203,7 +203,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object) /* {{{ *
|
||||||
|
|
||||||
ZEND_API ZEND_COLD zend_property_info *zend_get_property_info_for_slot_slow(zend_object *obj, zval *slot)
|
ZEND_API ZEND_COLD zend_property_info *zend_get_property_info_for_slot_slow(zend_object *obj, zval *slot)
|
||||||
{
|
{
|
||||||
uintptr_t offset = (uintptr_t)slot - (uintptr_t)obj->properties_table;
|
uintptr_t offset = OBJ_PROP_SLOT_TO_OFFSET(obj, slot);
|
||||||
zend_property_info *prop_info;
|
zend_property_info *prop_info;
|
||||||
ZEND_HASH_MAP_FOREACH_PTR(&obj->ce->properties_info, prop_info) {
|
ZEND_HASH_MAP_FOREACH_PTR(&obj->ce->properties_info, prop_info) {
|
||||||
if (prop_info->offset == offset) {
|
if (prop_info->offset == offset) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue