ID:          46903
 Updated by:  fel...@php.net
 Reported By: robin_fernandes at uk dot ibm dot com
-Status:      Open
+Status:      Assigned
 Bug Type:    Output Control
 PHP Version: 6CVS-2008-12-18 (snap)
-Assigned To: 
+Assigned To: robinf
 New Comment:

Commit it :)


Previous Comments:
------------------------------------------------------------------------

[2008-12-18 14:40:09] robin_fernandes at uk dot ibm dot com

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 this bug report at http://bugs.php.net/?id=46903&edit=1

Reply via email to