#17825 [Asn->Csd]: problem using chunk_size argument to ob_start()
| From: | yohgaki@php.net | Date: | Tue, 01 Oct 2002 10:09:10 +0000 |
| Subject: | #17825 [Asn->Csd]: problem using chunk_size argument to ob_start() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-20899@lists.php.net to get a copy of this message | ||
ID: 17825
Updated by: yohgaki@php.net
Reported By: hhr02368@haris.org
-Status: Assigned
+Status: Closed
Bug Type: Output Control
Operating System: linux redhat 6.2
PHP Version: 4.3.0-dev
Assigned To: yohgaki
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
It was rather obvious :)
Previous Comments:
------------------------------------------------------------------------
[2002-10-01 04:59:17] yohgaki@php.net
Found what's wrong.
OG(active_ob_buffer).output_handler is destoryed after 1st call for
some reason.
Fix will be committed in a few days.
------------------------------------------------------------------------
[2002-09-30 17:39:38] sniper@php.net
be specific about the version..
------------------------------------------------------------------------
[2002-09-29 22:40:11] iliaa@php.net
verified & bumped version #.
------------------------------------------------------------------------
[2002-06-18 21:35:40] hhr02368@haris.org
Test environment:
A) apache 1.3.24, PHP 4.2.1 built as apache module
B) apache 1.3.23, PHP 4.1.2 built as apache module
The following program demonstrates the change in behavior between
versions 4.1.2 and 4.2.1:
<?
function output_handler($buffer, $mode) {
static $s_count;
$s_count++;
error_log("output_handler: s_count=$s_count " .
"strlen(buffer)=" . strlen($buffer) . "\n",
3, '/tmp/logfile');
return strtoupper($buffer);
}
header("Content-Type: text/plain");
ob_start('output_handler', 400);
for ($i=0; $i<20; $i++) {
echo sprintf("%5d the quick brown fox jumped over the lazy dog\n",
$i);
}
?>
Our expectation is that output_handler() will get called
multiple times, every time there are more than 100 bytes
of output to process or when explicit ob_flush is called.
Running with php 4.2.1 (test environment A) output_handler()
is called only once:
> cat /tmp/logfile
> output_handler: s_count=1 strlen(buffer)=102
The browser displays:
> 0 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG
> 1 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG
> 2 the quick brown fox jumped over the lazy dog
> 3 the quick brown fox jumped over the lazy dog
> 4 the quick brown fox jumped over the lazy dog
It appears that after the 1st time, our output is sent to the
browser unprocessed. If using ob_gzhandler() the results are
more unpleasant as the first buffer is compressed but the
rest are sent uncompressed, confusing the browser.
If ob_start() is called without the 2nd argument then
output_handler() is called once to process the complete
output. This results in correct output but is undesirable
because for some scripts this buffer can be very large.
Running the same program with php 4.1.2 (test environment B)
output_handler() is called 3 times:
> cat /tmp/logfile
> output_handler: s_count=1 strlen(buffer)=102
> output_handler: s_count=2 strlen(buffer)=102
> output_handler: s_count=3 strlen(buffer)=51
The browser displays:
> 0 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG
> 1 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG
> 2 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG
> 3 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG
> 4 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG
> 5 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17825&edit=1