-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Clear output handler status flags during handler initialization #13087
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
Conversation
@Girgias: pinging you because you reviewed all the applicable doc changes. TL;DR: this change will clear all user supplied flags that are supposed to be set internally only. |
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.
I think the change makes sense, will wait for @bukka's opinion.
This might also require an email to the internals mailing list, just to ensure nobody is opposed.
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.
LGTM
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.
I think it makes sense. Allowing setting those status flags seems like unintended and it's also not documented. I think we should add a line to UPGRADING in case someone uses it. Even if there's some use case, we should probably introduce better and documented API.
When initializing output handlers, clears user supplied handler status flags (see all flags listed below).
Output buffers accept a bitflag for setting the operations allowed on the buffer (see
handler ability flags
below). These flags, along with the flags for handler type (seehandler types
below) and handler status (seehandler status flags
below) are stored in one bitmask internally. When initializing the buffer, the bits that represent handler type are cleared and set internally (here and here), and the rest of the user supplied bitmask is left unchanged. This has the (IMO unintended) side effect that the handler processing status can be set by the code starting the buffer.Setting the
PHP_OUTPUT_HANDLER_STARTED
status flag manually will prevent the passing of thePHP_OUTPUT_HANDLER_START
flag to the output handler function which can be used by user defined functions to identify the first time the output buffer calls the handler function. Internally, this flag cannot be set as it will only be set after the handler function first gets called.Setting the
PHP_OUTPUT_HANDLER_DISABLED
status flag manually will prevent ob_end_clean, ob_get_clean, ob_end_flush and ob_get_flush from calling the handler function. Internally, this flag will only be set when a handler function fails or whenphp_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL)
is called.php-src/main/php_output.h
Lines 31 to 44 in 73722df