[php-src] Issue #16133: Bug: don't call disabled output buffer
| From: | kkmuffme | Date: | Mon, 30 Sep 2024 16:39:03 +0000 |
| Subject: | [php-src] Issue #16133: Bug: don't call disabled output buffer | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247946@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/16133
Author: kkmuffme
### Description
When you check if
PHP_OUTPUT_HANDLER_DISABLED is set with var_dump(
ob_get_status( true ) ); you see it's set. The ob callback is still called every time,
however with an empty string.
If the output buffer is disabled, the callback shouldn't be called at all.
https://3v4l.org/AbBH1
The following code:
```php
<?php
function my_cb( $a ) {
return 'AAA' . PHP_EOL . $a . 'BBB' . PHP_EOL;
}
function my_cb2( $a ) {
if ( $a === 'XXX' ) {
return false;
}
if ( $a === '' ) {
$a = 'EMPTY';
}
return 'CCC' . PHP_EOL . $a . 'DDD' . PHP_EOL;
}
ob_start( 'my_cb', 0 );
ob_start( 'my_cb2', 0 );
echo "XXX";
ob_flush();
#var_dump( ob_get_status( true ) );
echo "ONE" . PHP_EOL;
ob_flush();
echo "TWO" . PHP_EOL;
ob_flush();
```
Resulted in this output:
```
AAA
XXXONE
CCC
EMPTYDDD
TWO
CCC
EMPTYDDD
BBB
```
But I expected this output instead:
```
AAA
XXXONE
TWO
BBB
```
### PHP Version
PHP 8.3.x
### Operating System
_No response_