From:             michael at heuser dot dk
Operating system: linux
PHP version:      4.3.1
PHP Bug Type:     Output Control
Bug description:  ob_start calls call back function before flush

When turning on output buffering and setting a call back function like:
        ob_start('callback_function');
The function is called right away. Not just in the end of the script.

Try this sample:
        ob_start('ob_gzhandler');
        ob_end_clean();

        echo "Step 1<br>\n";
        flush();
        sleep(1);

        echo "Step 2<br>\n";
        flush();

Function ob_end_clean should cancel the buffering and it dose, but
ob_gzhandler is already called. It is called when ob_start is turned one.
Now the script fails because the function ob_gzhandler has already set
Content-Encoding header (meaning the browser expects compressed content).

A simple one:
        function callback_function($content) {
                die("Stop!");
                return $content;
        }
        ob_start('callback_function');
        ob_end_clean();

        echo "Step 1<br>\n";
        flush();
        sleep(1);

        echo "Step 2<br>\n";
        flush();

The script is stops before ob_end_clean is called.

I think that the problem is general. I have tested the problem on more
than one computer.
The newest installation was a preinstalled Red Hat with a PHP version
4.3.1


-- 
Edit bug report at http://bugs.php.net/?id=22945&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22945&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22945&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22945&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22945&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22945&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22945&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22945&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22945&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22945&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22945&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22945&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22945&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22945&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22945&r=gnused

Reply via email to