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 38----( chunk_size: -1, output append size: 1 )---- 39f[call:1; len:8]12345678 40 41----( chunk_size: 0, output append size: 1 )---- 42f[call:1; len:8]12345678 43 44----( chunk_size: 1, output append size: 1 )---- 45f[call:1; len:1]1 46f[call:2; len:1]2 47f[call:3; len:1]3 48f[call:4; len:1]4 49f[call:5; len:1]5 50f[call:6; len:1]6 51f[call:7; len:1]7 52f[call:8; len:1]8 53f[call:9; len:0] 54 55----( chunk_size: 2, output append size: 1 )---- 56f[call:1; len:2]12 57f[call:2; len:2]34 58f[call:3; len:2]56 59f[call:4; len:2]78 60f[call:5; len:0] 61 62----( chunk_size: 3, output append size: 1 )---- 63f[call:1; len:3]123 64f[call:2; len:3]456 65f[call:3; len:2]78 66 67----( chunk_size: 4, output append size: 1 )---- 68f[call:1; len:4]1234 69f[call:2; len:4]5678 70f[call:3; len:0] 71 72----( chunk_size: 5, output append size: 1 )---- 73f[call:1; len:5]12345 74f[call:2; len:3]678 75 76----( chunk_size: 6, output append size: 1 )---- 77f[call:1; len:6]123456 78f[call:2; len:2]78 79 80----( chunk_size: 7, output append size: 1 )---- 81f[call:1; len:7]1234567 82f[call:2; len:1]8 83 84----( chunk_size: 8, output append size: 1 )---- 85f[call:1; len:8]12345678 86f[call:2; len:0] 87 88----( chunk_size: 9, output append size: 1 )---- 89f[call:1; len:8]12345678 90 91----( chunk_size: -1, output append size: 4 )---- 92f[call:1; len:8]12345678 93 94----( chunk_size: 0, output append size: 4 )---- 95f[call:1; len:8]12345678 96 97----( chunk_size: 1, output append size: 4 )---- 98f[call:1; len:4]1234 99f[call:2; len:4]5678 100f[call:3; len:0] 101 102----( chunk_size: 2, output append size: 4 )---- 103f[call:1; len:4]1234 104f[call:2; len:4]5678 105f[call:3; len:0] 106 107----( chunk_size: 3, output append size: 4 )---- 108f[call:1; len:4]1234 109f[call:2; len:4]5678 110f[call:3; len:0] 111 112----( chunk_size: 4, output append size: 4 )---- 113f[call:1; len:4]1234 114f[call:2; len:4]5678 115f[call:3; len:0] 116 117----( chunk_size: 5, output append size: 4 )---- 118f[call:1; len:8]12345678 119f[call:2; len:0] 120 121----( chunk_size: 6, output append size: 4 )---- 122f[call:1; len:8]12345678 123f[call:2; len:0] 124 125----( chunk_size: 7, output append size: 4 )---- 126f[call:1; len:8]12345678 127f[call:2; len:0] 128 129----( chunk_size: 8, output append size: 4 )---- 130f[call:1; len:8]12345678 131f[call:2; len:0] 132 133----( chunk_size: 9, output append size: 4 )---- 134f[call:1; len:8]12345678 135