Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ext/standard/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,16 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
}
ZEND_GUARD_OR_GC_PROTECT_RECURSION(guard, DEBUG, zobj);

myht = zend_get_properties_for(struc, ZEND_PROP_PURPOSE_DEBUG);
// GH-16317: for user classes with __debugInfo() always call that
if (ce->type == ZEND_USER_CLASS && ce->__debugInfo != NULL) {
int is_temp;
myht = (std_object_handlers.get_debug_info)(zobj, &is_temp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_debug_info is technically an optional handler.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally it is optional, but can it ever be unset from the global std_object_handlers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the default handlers may be removed. I don't know exactly why you would do that, but it is currently marked as optional, and its existence is checked for within zend_std_get_properties_for().

if (myht && !is_temp) {
GC_TRY_ADDREF(myht);
}
} else {
myht = zend_get_properties_for(struc, ZEND_PROP_PURPOSE_DEBUG);
}
class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc));
const char *prefix = php_var_dump_object_prefix(Z_OBJ_P(struc));

Expand Down