[php-src] PR #13087: Clear output handler status flags during handler initialization
| From: | haszi | Date: | Sun, 07 Jan 2024 21:42:23 +0000 |
| Subject: | [php-src] PR #13087: Clear output handler status flags during handler initialization | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-24686@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/13087
Author: haszi
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 (see handler
types below) and handler status (see handler 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](https://github.com/php/php-src/blob/73722df4390b4fb467062815ccc426e990b517a1/main/output.c#L481)
and
[here](https://github.com/php/php-src/blob/73722df4390b4fb467062815ccc426e990b517a1/main/output.c#L507)),
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
the PHP_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 when
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL) is called.
https://github.com/php/php-src/blob/73722df4390b4fb467062815ccc426e990b517a1/main/php_output.h#L31-L44