php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22945 ob_start calls call back function before flush
Submitted: 2003-03-28 18:14 UTC Modified: 2003-04-02 10:35 UTC
From: michael at heuser dot dk Assigned:
Status: Closed Package: Output Control
PHP Version: 4.3.1 OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michael at heuser dot dk
New email:
PHP Version: OS:

 

 [2003-03-28 18:14 UTC] michael at heuser dot dk
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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-02 10:35 UTC] sniper@php.net
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.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 13:01:36 2025 UTC