Bug #64977 [Opn->Ana]: ob_start() fails when passed default parameters
Edit report at https://bugs.php.net/bug.php?id=64977&edit=1
ID: 64977
Updated by: ab@php.net
Reported by: rewilliams at newtekemail dot com
Summary: ob_start() fails when passed default parameters
-Status: Open
+Status: Analyzed
Type: Bug
Package: Scripting Engine problem
PHP Version: 5.5.0RC2
Block user comment: N
Private report: N
New Comment:
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
docs.
Previous Comments:
------------------------------------------------------------------------
[2013-06-05 20:03:11] rewilliams at newtekemail dot com
Description:
------------
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
5.5.
Test script:
---------------
<?php
ob_start(null, 0, true);
echo 'hello world';
$foo = ob_get_clean();
var_dump($foo)
?>
Expected result:
----------------
string(11) "hello world"
Actual result:
--------------
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
hello world
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"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64977&edit=1
Thread (3 messages)