#42660 [NEW]: ob_start(): documentation of chunk_size param is inaccurate

From: Date: Thu, 13 Sep 2007 15:48:50 +0000
Subject: #42660 [NEW]: ob_start(): documentation of chunk_size param is inaccurate
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9@lists.php.net to get a copy of this message
From: robin_fernandes at uk dot ibm dot com Operating system: N/A PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: ob_start(): documentation of chunk_size param is inaccurate Description: ------------ The manual for ob_start() provides the following description for the chunk_size parameter: "If the optional parameter chunk_size is passed, the callback function is called on every first newline after chunk_size bytes of output. Default value 0 means that the function is called only in the end, other special value 1 sets chunk_size to 4096." I believe There are two problems with that statement. 1. Passing the chunk_size does not just cause the callback function to be called. It causes a flush of the buffer, which will in turn trigger the callback function, if one is available. This is important, since the documentation explains how it is possible to set a chunk_size and erase flag without a callback function by providing null as the first argument. 2. The flush does not occur "on every first newline after chunk_size bytes". It occurs after any append to the buffer which has caused the buffer length to equal or exceed the chunk_size. Newlines are not treated differently from other characters. Evidence for this is in the code in output.c in php_ob_append(): if (OG(active_ob_buffer).chunk_size && OG(active_ob_buffer).text_length >= OG(active_ob_buffer).chunk_size) { php_end_ob_buffer(1, 1 TSRMLS_CC); return; } So, I think the statement should read: If the optional parameter chunk_size is passed, the buffer will be flushed after any output call which causes the buffer's length to equal or exceed chunk_size. There are two special values: 0 (default value): the buffer is flushed only when explicitly called for (for example with ob_flush()) or at the end of the request. 1: equivalent to setting chunk_size to 4096. Note that flushing the buffer will trigger the callback function, if it is available. Reproduce code: --------------- Here is a test demonstrating that a buffer is flushed after an output call causes its length to equal or exceed chunk_size, and that this is not dependent on the occurrence of new lines: http://pastebin.com/f46cbdf76 Expected result: ---------------- N/A Actual result: -------------- N/A -- Edit bug report at http://bugs.php.net/?id=42660&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42660&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42660&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42660&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42660&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42660&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42660&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42660&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42660&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42660&r=support Expected behavior: http://bugs.php.net/fix.php?id=42660&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42660&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42660&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42660&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42660&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42660&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42660&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42660&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42660&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42660&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42660&r=mysqlcfg

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