Skip to content

Commit 3ce7bf2

Browse files
haszibukka
authored andcommitted
Clear handler status flag in handler init
Closes GH-13087
1 parent 6647d5f commit 3ce7bf2

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ PHP NEWS
7373
. Added X509_PURPOSE_OCSP_HELPER and X509_PURPOSE_TIMESTAMP_SIGN constants.
7474
(Vincent Jardin)
7575

76+
- Output:
77+
. Clear output handler status flags during handler initialization. (haszi)
78+
7679
- PDO:
7780
. Fixed setAttribute and getAttribute. (SakiTakamachi)
7881
. Implemented PDO driver-specific subclasses RFC. (danack, kocsismate)

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ PHP 8.4 UPGRADE NOTES
313313
. New serial_hex parameter added to openssl_csr_sign to allow setting serial
314314
number in the hexadecimal format.
315315

316+
- Output:
317+
. Output handler status flags passed to the flags parameter of ob_start
318+
are now cleared.
319+
316320
- PDO:
317321
. getAttribute, enabled to get the value of ATTR_STRINGIFY_FETCHES.
318322

main/output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler,
478478
default:
479479
user = ecalloc(1, sizeof(php_output_handler_user_func_t));
480480
if (SUCCESS == zend_fcall_info_init(output_handler, 0, &user->fci, &user->fcc, &handler_name, &error)) {
481-
handler = php_output_handler_init(handler_name, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_USER);
481+
handler = php_output_handler_init(handler_name, chunk_size, PHP_OUTPUT_HANDLER_ABILITY_FLAGS(flags) | PHP_OUTPUT_HANDLER_USER);
482482
ZVAL_COPY(&user->zoh, output_handler);
483483
handler->func.user = user;
484484
} else {
@@ -504,7 +504,7 @@ PHPAPI php_output_handler *php_output_handler_create_internal(const char *name,
504504
php_output_handler *handler;
505505
zend_string *str = zend_string_init(name, name_len, 0);
506506

507-
handler = php_output_handler_init(str, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_INTERNAL);
507+
handler = php_output_handler_init(str, chunk_size, PHP_OUTPUT_HANDLER_ABILITY_FLAGS(flags) | PHP_OUTPUT_HANDLER_INTERNAL);
508508
handler->func.internal = output_handler;
509509
zend_string_release_ex(str, 0);
510510

main/php_output.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#define PHP_OUTPUT_HANDLER_DISABLED 0x2000
4444
#define PHP_OUTPUT_HANDLER_PROCESSED 0x4000
4545

46+
#define PHP_OUTPUT_HANDLER_ABILITY_FLAGS(bitmask) ((bitmask) & ~0xf00f)
47+
4648
/* handler op return values */
4749
typedef enum _php_output_handler_status_t {
4850
PHP_OUTPUT_HANDLER_FAILURE,

tests/output/ob_start_flags.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
ob_start(): Ensure that user supplied handler type and status flags are erased
3+
--FILE--
4+
<?php
5+
define('PHP_OUTPUT_HANDLER_TYPE_INTERNAL', 0);
6+
define('PHP_OUTPUT_HANDLER_TYPE_USER', 1);
7+
8+
ob_start(
9+
fn ($s) => $s,
10+
0,
11+
PHP_OUTPUT_HANDLER_STDFLAGS |
12+
PHP_OUTPUT_HANDLER_TYPE_INTERNAL |
13+
PHP_OUTPUT_HANDLER_STARTED |
14+
PHP_OUTPUT_HANDLER_DISABLED |
15+
PHP_OUTPUT_HANDLER_PROCESSED
16+
);
17+
18+
$bitmask = ob_get_status()['flags'];
19+
20+
var_dump($bitmask & PHP_OUTPUT_HANDLER_STDFLAGS);
21+
var_dump($bitmask & PHP_OUTPUT_HANDLER_TYPE_USER);
22+
var_dump($bitmask & PHP_OUTPUT_HANDLER_STARTED);
23+
var_dump($bitmask & PHP_OUTPUT_HANDLER_DISABLED);
24+
var_dump($bitmask & PHP_OUTPUT_HANDLER_PROCESSED);
25+
?>
26+
--EXPECT--
27+
int(112)
28+
int(1)
29+
int(0)
30+
int(0)
31+
int(0)

0 commit comments

Comments
 (0)