1--TEST-- 2ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size. 3--INI-- 4opcache.optimization_level=0 5--FILE-- 6<?php 7/* 8 * proto bool ob_start([ string|array user_function [, int chunk_size [, bool erase]]]) 9 * Function is implemented in main/output.c 10*/ 11// In HEAD, $chunk_size value of 1 should not have any special behaviour (http://marc.info/?l=php-internals&m=123476465621346&w=2). 12function callback($string) { 13 global $callback_invocations; 14 $callback_invocations++; 15 $len = strlen($string); 16 return "f[call:$callback_invocations; len:$len]$string\n"; 17} 18 19for ($cs=-1; $cs<10; $cs++) { 20 echo "\n----( chunk_size: $cs, output append size: 1 )----\n"; 21 $callback_invocations=0; 22 ob_start('callback', $cs); 23 echo '1'; echo '2'; echo '3'; echo '4'; echo '5'; echo '6'; echo '7'; echo '8'; 24 ob_end_flush(); 25} 26 27for ($cs=-1; $cs<10; $cs++) { 28 echo "\n----( chunk_size: $cs, output append size: 4 )----\n"; 29 $callback_invocations=0; 30 ob_start('callback', $cs); 31 echo '1234'; echo '5678'; 32 ob_end_flush(); 33} 34 35?> 36--EXPECTF-- 37----( chunk_size: -1, output append size: 1 )---- 38f[call:1; len:8]12345678 39 40----( chunk_size: 0, output append size: 1 )---- 41f[call:1; len:8]12345678 42 43----( chunk_size: 1, output append size: 1 )---- 44f[call:1; len:1]1 45f[call:2; len:1]2 46f[call:3; len:1]3 47f[call:4; len:1]4 48f[call:5; len:1]5 49f[call:6; len:1]6 50f[call:7; len:1]7 51f[call:8; len:1]8 52f[call:9; len:0] 53 54----( chunk_size: 2, output append size: 1 )---- 55f[call:1; len:2]12 56f[call:2; len:2]34 57f[call:3; len:2]56 58f[call:4; len:2]78 59f[call:5; len:0] 60 61----( chunk_size: 3, output append size: 1 )---- 62f[call:1; len:3]123 63f[call:2; len:3]456 64f[call:3; len:2]78 65 66----( chunk_size: 4, output append size: 1 )---- 67f[call:1; len:4]1234 68f[call:2; len:4]5678 69f[call:3; len:0] 70 71----( chunk_size: 5, output append size: 1 )---- 72f[call:1; len:5]12345 73f[call:2; len:3]678 74 75----( chunk_size: 6, output append size: 1 )---- 76f[call:1; len:6]123456 77f[call:2; len:2]78 78 79----( chunk_size: 7, output append size: 1 )---- 80f[call:1; len:7]1234567 81f[call:2; len:1]8 82 83----( chunk_size: 8, output append size: 1 )---- 84f[call:1; len:8]12345678 85f[call:2; len:0] 86 87----( chunk_size: 9, output append size: 1 )---- 88f[call:1; len:8]12345678 89 90----( chunk_size: -1, output append size: 4 )---- 91f[call:1; len:8]12345678 92 93----( chunk_size: 0, output append size: 4 )---- 94f[call:1; len:8]12345678 95 96----( chunk_size: 1, output append size: 4 )---- 97f[call:1; len:4]1234 98f[call:2; len:4]5678 99f[call:3; len:0] 100 101----( chunk_size: 2, output append size: 4 )---- 102f[call:1; len:4]1234 103f[call:2; len:4]5678 104f[call:3; len:0] 105 106----( chunk_size: 3, output append size: 4 )---- 107f[call:1; len:4]1234 108f[call:2; len:4]5678 109f[call:3; len:0] 110 111----( chunk_size: 4, output append size: 4 )---- 112f[call:1; len:4]1234 113f[call:2; len:4]5678 114f[call:3; len:0] 115 116----( chunk_size: 5, output append size: 4 )---- 117f[call:1; len:8]12345678 118f[call:2; len:0] 119 120----( chunk_size: 6, output append size: 4 )---- 121f[call:1; len:8]12345678 122f[call:2; len:0] 123 124----( chunk_size: 7, output append size: 4 )---- 125f[call:1; len:8]12345678 126f[call:2; len:0] 127 128----( chunk_size: 8, output append size: 4 )---- 129f[call:1; len:8]12345678 130f[call:2; len:0] 131 132----( chunk_size: 9, output append size: 4 )---- 133f[call:1; len:8]12345678 134