go to bug id or search bugs for
Calling ob_start() with explicit parameters that match the defaults (using null to
get past the first one, as documented), the various functions to end output
buffering generate notices, which are also added to the buffered content. For
example, ob_get_clean() returns the following:
ob_get_clean(): failed to discard buffer of default output handler [...]
ob_get_clean(): failed to delete buffer of default output handler (0) in
It looks like output is spit out just as though buffering were not enabled, *and*
the buffer gets saved - albeit with the buffering-related notices mixed in.
Testing at <http://sandbox.onlinephpfunctions.com>, it appears the bug was
introduced in 5.4 (it works in 5.3.23) and continues through the latest version of
ob_start(null, 0, true);
echo 'hello world';
$foo = ob_get_clean();
string(11) "hello world"
PHP Notice: ob_get_clean(): failed to discard buffer of default output handler
(0) in [...] on line 5
PHP Notice: ob_get_clean(): failed to delete buffer of default output handler (0)
in [...] on line 5
Notice: ob_get_clean(): failed to discard buffer of default output handler (0) in
[...] on line 5
Notice: ob_get_clean(): failed to delete buffer of default output handler (0) in
[...] on line 5
string(11) "hello world"
Add a Patch
Add a Pull Request
This is more like a documentation bug. There is a bunch of constants
undocumented http://lxr.php.net/xref/PHP_5_4/main/output.c#204 . Also the third
ob_start() argument can be not only true/false, you can pass various flags
there. As such, if you change your first line
ob_start(null, 0, PHP_OUTPUT_HANDLER_REMOVABLE)
no warnings will be to see.
Please change this bug to be a documentation one. Or you could even fix the
> This is more like a documentation bug. There is a bunch of constants
> undocumented http://lxr.php.net/xref/PHP_5_4/main/output.c#204 . Also the
> ob_start() argument can be not only true/false, you can pass various flags
> there. As such, if you change your first line
> ob_start(null, 0, PHP_OUTPUT_HANDLER_REMOVABLE)
> no warnings will be to see.
It works. But the "del" entry for ob_get_status() is never set with the default
value or the built-in constants on PHP 5.4. The "del" entry is always set on PHP
This is about correct. We missed to document the new flags parameter including
available constants for 5.4+
PHP_OUTPUT_HANDLER_REMOVABLE: whether ob_end_*() can be called
PHP_OUTPUT_HANDLER_CLEANABLE: whether ob_*_clean() can be called
PHP_OUTPUT_HANDLER_FLUSHABLE: whether ob_flush() can be called
PHP_OUTPUT_HANDLER_STDFLAGS: all above OR'ed together
On another note: the "del" status array element is never set in 5.4+, the flags
entry will contain PHP_OUTPUT_HANDLER_REMOVABLE if it's deletable.
The following page also should be updated.
There is no description for PHP_OUTPUT_HANDLER_CLEANABLE,
The list of all constants added in PHP 5.4 is found in the following instruction
Related To: Bug #62796
Mike, what happens if you pass true as the "flags" parameter in 5.4+? It looks
easier to ask you than figure out the code paths, honestly, and we need to cover
the BC story somehow.
Duh, unfortunately pretty much the opposite:
bool(true) -> int(1) & ~0xf == 0
The first bits are reserved for the OB handler type (internal/user) and thus ignored, so flags end up as zero, which in turn means the handler is neither removeable, nor flushable, nor cleanable.
I suspect, I could have done better.
We probably should have picked that up at the time. Whoops.
OK, I'll assign this to myself and figure out how to document it. Probably won't
Automatic comment from SVN on behalf of aharvey
Log: Document the ob_start() changes in PHP 5.4.
Mostly fixes doc bug #64977 (ob_start() fails when passed default parameters).
OK, documentation is done except for the PHP_OUTPUT_BUFFER_STARTED and
PHP_OUTPUT_BUFFER_DISABLED constants, mostly because I can't figure out how
Mike, help please? :)
PHP_OUTPUT_HANDLER_STARTED just indicates that the handler has been called previously with PHP_OUTPUT_HANDLER_START set, so it would not get that flag again, unless it has also seen PHP_OUTPUT_HANDLER_FINAL in the meantime.
handler(PHP_OUTPUT_HANDLER_START) => flags |= STARTED
handler(PHP_OUTPUT_HANDLER_FINAL) => flags ^= STARTED
Internal output handlers can mark them self as disabled with php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE), when they f.e. detect an error; see README.NEW-OUTPUT-API.
Also, when a call to an internal or userland handler fails, or the userland handler returns FALSE.
See also Doc Bug #62019