-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate returning non-string values from a user output handler #18932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Deprecate returning non-string values from a user output handler #18932
Conversation
And update tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this! I added a few comments and I think the reason you don't get the "correct" name for anonymous functions should be fixed with #19011
int handler_count = php_output_get_level(); | ||
if (handler_count) { | ||
php_output_handler **handlers = (php_output_handler **) zend_stack_base(&OG(handlers)); | ||
for (int iii = 0; iii < handler_count; ++iii) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a better variable name than iii
?
/* user handler may have returned TRUE */ | ||
status = PHP_OUTPUT_HANDLER_NO_DATA; | ||
if (Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) { | ||
convert_to_string(&retval); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may fail with non-stringable objects, also I would prefer zend_try_get_string()
rather than converting the ZVAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is unchanged from the original, I'd rather not change things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but can you add a test with a non-stringable object being returned from an output handler?
https://wiki.php.net/rfc/deprecations_php_8_4