#44150 [NEW]: ob_start(): documentation for "output_callback" parameter innaccurate
| From: | robin_fernandes at uk dot ibm dot com | Date: | Mon, 18 Feb 2008 13:15:45 +0000 |
| Subject: | #44150 [NEW]: ob_start(): documentation for "output_callback" parameter innaccurate | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-523@lists.php.net to get a copy of this message | ||
From: robin_fernandes at uk dot ibm dot com
Operating system: *
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: ob_start(): documentation for "output_callback" parameter innaccurate
Description:
------------
The description of the "output_callback" parameter in the doc for
ob_start() states that:
"The function will be called when ob_end_flush() is called, or when the
output buffer is flushed to the browser at the end of the request."
The testcase below shows 3 undocumented cases where the callback is
invoked:
- when the output buffer is flushed with ob_flush()
- when the output buffer is cleaned with ob_clean()
- when the output buffer is cleaned with ob_end_clean().
This could be indicated by adapting the description as follows:
"The callback function will be invoked when the output buffer is flushed
explicitly (using ob_flush() or ob_end_flush()), when it is flushed
implicitly at the end of the request, or when it is cleaned (using
ob_clean() or ob_end_clean()). In the case where the buffer is cleaned, the
callback's return value is ignored."
Reproduce code:
---------------
<?php
$a = '';
function output_handler($buffer, $mode) {
global $a;
static $i=0;
$i++;
$a .= "\n-->$i: In output_handler($buffer, $mode)";
return "Hello";
}
echo "About to start buffer.\n";
ob_start('output_handler');
echo "About to call 'ob_flush()'";
ob_flush();
echo "About to call 'ob_clean()'";
ob_clean();
echo "About to call 'ob_end_clean()'";
ob_end_clean();
echo "\nEnded buffer.\n";
echo "\n\nShow when the callback was really invoked:";
echo $a;
?>
Expected result:
----------------
N/A
Actual result:
--------------
About to start buffer.
Hello
Ended buffer.
Show when the callback was really invoked:
-->1: In output_handler(About to call 'ob_flush()', 3)
-->2: In output_handler(About to call 'ob_clean()', 2)
-->3: In output_handler(About to call 'ob_end_clean()', 4)
--
Edit bug report at http://bugs.php.net/?id=44150&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44150&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44150&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44150&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44150&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=44150&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44150&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44150&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44150&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44150&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44150&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=44150&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=44150&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44150&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44150&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44150&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44150&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44150&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44150&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44150&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44150&r=mysqlcfg