Skip to content

Commit 599078f

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Add forgotten NEWS item Partially fix GH-16317: DOM classes do not allow __debugInfo() overrides to work
2 parents 0f63407 + 390e243 commit 599078f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ext/dom/php_dom.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ static void dom_unset_property(zend_object *object, zend_string *member, void **
488488
zend_std_unset_property(object, member, cache_slot);
489489
}
490490

491+
/* This custom handler is necessary to avoid a recursive construction of the entire subtree. */
491492
static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */
492493
{
493494
dom_object *obj = php_dom_obj_from_obj(object);
@@ -498,6 +499,11 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
498499
dom_prop_handler *entry;
499500
zend_string *object_str;
500501

502+
/* As we have a custom implementation, we must manually check for overrides. */
503+
if (object->ce->__debugInfo) {
504+
return zend_std_get_debug_info(object, is_temp);
505+
}
506+
501507
*is_temp = 1;
502508

503509
std_props = zend_std_get_properties(object);

ext/dom/tests/gh16317.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-16317 (DOM classes do not allow __debugInfo() overrides to work)
3+
--FILE--
4+
<?php
5+
6+
class Demo extends DOMNode {
7+
public function __construct() {}
8+
public function __debugInfo(): array {
9+
return ['x' => 'y'];
10+
}
11+
}
12+
13+
var_dump(new Demo());
14+
15+
?>
16+
--EXPECT--
17+
object(Demo)#1 (1) {
18+
["x"]=>
19+
string(1) "y"
20+
}

0 commit comments

Comments
 (0)