ID:               17825
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Verified
 Bug Type:         Output Control
 Operating System: linux redhat 6.2
-PHP Version:      4.2.1
+PHP Version:      4.3.0
 New Comment:

verified & bumped version #.


Previous Comments:
------------------------------------------------------------------------

[2002-06-18 21:35:40] [EMAIL PROTECTED]

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

Reply via email to