Bug #64977 [Com]: ob_start() fails when passed default parameters

From: Date: Thu, 08 Aug 2013 06:12:40 +0000
Subject: Bug #64977 [Com]: ob_start() fails when passed default parameters
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10155@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64977&edit=1

 ID:                 64977
 Comment by:         masakielastic at gmail dot com
 Reported by:        rewilliams at newtekemail dot com
 Summary:            ob_start() fails when passed default parameters
 Status:             Analyzed
 Type:               Bug
 Package:            Documentation problem
 PHP Version:        5.5.0RC2
 Block user comment: N
 Private report:     N

 New Comment:

The following page also should be updated.

http://www.php.net/manual/en/outcontrol.constants.php

There is no description for PHP_OUTPUT_HANDLER_CLEANABLE, 
PHP_OUTPUT_HANDLER_DISABLED, PHP_OUTPUT_HANDLER_FLUSHABLE, 
PHP_OUTPUT_HANDLER_REMOVABLE, PHP_OUTPUT_HANDLER_STARTED, 
PHP_OUTPUT_HANDLER_STDFLAGS.

The list of all constants added in PHP 5.4 is found in the following instruction 
page.
http://www.php.net/manual/en/migration54.global-constants.php


Previous Comments:
------------------------------------------------------------------------
[2013-08-06 06:39:55] mike@php.net

This is about correct. We missed to document the new flags parameter including 
available constants for 5.4+

So:
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.

------------------------------------------------------------------------
[2013-08-06 03:15:38] kubo at iteman dot jp

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

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

------------------------------------------------------------------------
[2013-06-06 08:20:57] ab@php.net

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.

------------------------------------------------------------------------
[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 (11 messages)

« previous php.doc.bugs (#10155) next »