php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60468 Output is not discarded when ob_start() callback returns ""
Submitted: 2011-12-08 08:26 UTC Modified: 2012-01-17 12:23 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: vrana@php.net Assigned: mike (profile)
Status: Closed Package: Output Control
PHP Version: 5.4.0RC2 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vrana@php.net
New email:
PHP Version: OS:

 

 [2011-12-08 08:26 UTC] vrana@php.net
Description:
------------
If ob_start() callback returns an empty string then nothing should be printed. This is the current behavior in PHP 5.3. Behavior in PHP 5.4 is different - if a callback returns an empty string then the result is same as if it wouldn't be called at all - next call is prepended by last call value.

So there is no way for callback how to discard the output.


Test script:
---------------
ob_start(function ($s) {
	fwrite(STDERR, strlen($s) . "\n");
	if ($s == "b\n") {
		return $s;
	}
	return "";
}, 2);
echo "a\n";
echo "b\n";
exit;


Expected result:
----------------
2
2
b
0


Actual result:
--------------
2
4
4


Patches

handle-empty-string (last revision 2011-12-26 08:32 UTC by me at ktamura dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-26 08:33 UTC] me at ktamura dot com
That's my proposed patch, although I am fairly new to PHP internals and not sure 
how robust it is.
 [2012-01-17 12:23 UTC] mike@php.net
This bug has been fixed in SVN.

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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-01-17 12:23 UTC] mike@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: mike
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 16:01:31 2024 UTC