From:             robin_fernandes at uk dot ibm dot com
Operating system: 
PHP version:      6CVS-2008-12-18 (snap)
PHP Bug Type:     Output Control
Bug description:  ob_start(): Special $chunk_size value of 1 is not honoured in 
HEAD

Description:
------------
The doc for ob_start() states:
"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 . Default value 0 means that the function is called only
in the end, other special value 1 sets chunk_size  to 4096."

In HEAD, setting $chunk_size=1 actually does set the buffer threshold size
to 1 byte, rather than 4096 bytes as on 5_* and as documented.

Here's a simple patch for HEAD to restore the documented behaviour:

Index: output.c
===================================================================
RCS file: /repository/php-src/main/output.c,v
retrieving revision 1.214
diff -u -w -p -r1.214 output.c
--- output.c    18 Aug 2008 07:45:59 -0000      1.214
+++ output.c    18 Dec 2008 14:23:10 -0000
@@ -1342,6 +1342,8 @@ PHP_FUNCTION(ob_start)
        }
        if (chunk_size < 0) {
                chunk_size = 0;
+       } else if (chunk_size == 1) {
+               chunk_size = 4096;
        }
        
        if (SUCCESS != php_output_start_user(output_handler, chunk_size, flags
TSRMLS_CC)) {

Reproduce code:
---------------
<?php
function flushCounter($input) {
        static $counter=0;
        return '[' . ++$counter . "] $input \n";
}

// This should set the buffer size to 4096
ob_start('flushCounter', 1);

// Get the buffer size: 
$bufferInfo = ob_get_status(true);
var_dump($bufferInfo[0]['chunk_size']);

// If the buffer size is >1, these two chars should
// come out as part of a single flush:
echo "1";
echo "2";
?>

Expected result:
----------------
[1] int(4096)
12 


Actual result:
--------------
[1] int(1)
 
[2] 1 
[3] 2 
[4]  

-- 
Edit bug report at http://bugs.php.net/?id=46903&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46903&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46903&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46903&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46903&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46903&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46903&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46903&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46903&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46903&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46903&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46903&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46903&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46903&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46903&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46903&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46903&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46903&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46903&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46903&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46903&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46903&r=mysqlcfg

Reply via email to