diff --git a/NEWS b/NEWS index da8d58e4dc7..1ffcaa8b061 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,10 @@ PHP NEWS . Fixed bug GH-20085 (Assertion failure when combining lazy object get_properties exception with foreach loop). (nielsdos) +- DOM: + . Partially fixed bug GH-16317 (DOM classes do not allow + __debugInfo() overrides to work). (nielsdos) + - FPM: . Fixed bug GH-19974 (fpm_status_export_to_zval segfault for parallel execution). (Jakub Zelenka, txuna) diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 2438a081351..bcdd996f28e 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -492,6 +492,7 @@ static void dom_unset_property(zend_object *object, zend_string *member, void ** zend_std_unset_property(object, member, cache_slot); } +/* This custom handler is necessary to avoid a recursive construction of the entire subtree. */ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */ { 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) / dom_prop_handler *entry; zend_string *object_str; + /* As we have a custom implementation, we must manually check for overrides. */ + if (object->ce->__debugInfo) { + return zend_std_get_debug_info(object, is_temp); + } + *is_temp = 1; std_props = zend_std_get_properties(object); diff --git a/ext/dom/tests/gh16317.phpt b/ext/dom/tests/gh16317.phpt new file mode 100644 index 00000000000..870c337716f --- /dev/null +++ b/ext/dom/tests/gh16317.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-16317 (DOM classes do not allow __debugInfo() overrides to work) +--FILE-- + 'y']; + } +} + +var_dump(new Demo()); + +?> +--EXPECT-- +object(Demo)#1 (1) { + ["x"]=> + string(1) "y" +}