|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55428 E_RECOVERABLE_ERROR when output buffering in output buffering handler
Submitted: 2011-08-15 22:00 UTC Modified: 2014-12-27 19:57 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: nicolas dot grekas+php at gmail dot com Assigned: kalle (profile)
Status: Closed Package: Output Control
PHP Version: 5.3.6 OS: any
Private report: No CVE-ID: None
 [2011-08-15 22:00 UTC] nicolas dot grekas+php at gmail dot com
Output buffering inside output buffering handler is currently forbidden.

Ideally, this limitation could be removed, but as this may be too much work, I mostly really miss some way to test whether my code is running inside an output buffering handler or not (for example in a custom error handler).

PHP really miss a way to check for this situation.

Currently, when using output buffering in an output buffering handler context, an E_ERROR is thrown. Could it be possible to trigger an E_RECOVERABLE_ERROR instead? This would allow me to catch the situation and degrade gracefully.

Or maybe a new special function "ob_in_handler()", returning a boolean, is a better idea ?

Test script:


function abc()


Expected result:
PHP Catchable fatal error:  ob_start(): Cannot use output buffering in output buffering display handlers in [...] on line 5

Actual result:
PHP Fatal error:  ob_start(): Cannot use output buffering in output buffering display handlers in [...] on line 5


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-22 14:22 UTC]
I agree that we should change to use E_RECOVERABLE_ERROR here, as we don't leave the Engine in an unresolverable state (as the output layer is in the PHP part of the package).

As for the function suggestion, it doesn't make much sense to add a function to check if you are in a function for a function which purpose is to be used as a callback for ob_start().
 [2011-08-22 14:24 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: kalle
 [2014-12-27 19:57 UTC]
-Status: Assigned +Status: Closed
 [2014-12-27 19:57 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

This change is now implemented in PHP7.
 [2014-12-27 20:00 UTC]
Automatic comment from SVN on behalf of kalle
Log: Changelog for FR #55428
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 12:01:29 2024 UTC