Skip to content

Commit 39ef16a

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Partially fix GH-16317: DOM classes do not allow __debugInfo() overrides to work
2 parents 54d793d + 8e0504c commit 39ef16a

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ PHP NEWS
99
. Fixed bug GH-20085 (Assertion failure when combining lazy object
1010
get_properties exception with foreach loop). (nielsdos)
1111

12+
- DOM:
13+
. Partially fixed bug GH-16317 (DOM classes do not allow
14+
__debugInfo() overrides to work). (nielsdos)
15+
1216
- FPM:
1317
. Fixed bug GH-19974 (fpm_status_export_to_zval segfault for parallel
1418
execution). (Jakub Zelenka, txuna)

ext/dom/php_dom.c

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

495+
/* This custom handler is necessary to avoid a recursive construction of the entire subtree. */
495496
static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */
496497
{
497498
dom_object *obj = php_dom_obj_from_obj(object);
@@ -502,6 +503,11 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
502503
dom_prop_handler *entry;
503504
zend_string *object_str;
504505

506+
/* As we have a custom implementation, we must manually check for overrides. */
507+
if (object->ce->__debugInfo) {
508+
return zend_std_get_debug_info(object, is_temp);
509+
}
510+
505511
*is_temp = 1;
506512

507513
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)