@@ -113,61 +113,23 @@ PHPAPI int php_header_write(const char *str, uint str_length TSRMLS_DC)
113
113
}
114
114
}
115
115
116
- /* {{{ php_ob_default_buffer_size
117
- * Start output buffering */
118
- PHPAPI int php_ob_default_buffer_size (TSRMLS_D )
119
- {
120
- uint buffer_size = (uint )(PG (output_buffering ) > 1 ? PG (output_buffering ) : 4096 );
121
- if (OG (ob_nesting_level )== 0 && PG (double_buffering )!= 0 ) {
122
- buffer_size = (uint )(PG (double_buffering )) >= buffer_size ? (uint )(PG (double_buffering )) : 4 * buffer_size ;
123
- }
124
- return buffer_size ;
125
- }
126
- /* }}} */
127
-
128
116
/* {{{ php_start_ob_buffer
129
117
* Start output buffering */
130
118
PHPAPI int php_start_ob_buffer (zval * output_handler , uint chunk_size , zend_bool erase TSRMLS_DC )
131
119
{
132
- uint initial_chunk_size , initial_size , block_size ;
133
-
134
- if (OG (ob_lock )) {
135
- php_error_docref ("ref.outcontrol" TSRMLS_CC , E_ERROR , "Cannot use output buffering in output buffering display handlers" );
136
- return FAILURE ;
137
- }
138
- if (OG (ob_nesting_level )== 0 && PG (double_buffering )) {
139
- initial_chunk_size = php_ob_default_buffer_size (TSRMLS_C );
140
- initial_size = 4 * initial_chunk_size ;
141
- block_size = initial_chunk_size ;
142
- php_ob_init (initial_size , block_size , NULL , initial_chunk_size , erase TSRMLS_CC );
143
- }
144
- if (chunk_size < 2 ) {
145
- chunk_size = php_ob_default_buffer_size (TSRMLS_C );
146
- }
147
- block_size = chunk_size ;
148
- initial_size = block_size ;
149
- return php_ob_init (initial_size , block_size , output_handler , chunk_size , erase TSRMLS_CC );
150
- }
151
- /* }}} */
120
+ uint initial_size , block_size ;
152
121
153
- /* {{{ php_start_ob_buffer_nc
154
- * Start output buffering */
155
- PHPAPI int php_start_ob_buffer_ibc (zval * output_handler , uint initial_size , uint block_size , uint chunk_size , zend_bool erase TSRMLS_DC )
156
- {
157
122
if (OG (ob_lock )) {
158
123
php_error_docref ("ref.outcontrol" TSRMLS_CC , E_ERROR , "Cannot use output buffering in output buffering display handlers" );
159
124
return FAILURE ;
160
125
}
161
- if (chunk_size == 0 ) {
126
+ if (chunk_size ) {
127
+ initial_size = (chunk_size * 3 /2 );
128
+ block_size = chunk_size /2 ;
129
+ } else {
130
+ initial_size = 40 * 1024 ;
162
131
block_size = 10 * 1024 ;
163
- initial_size = 4 * block_size ;
164
- } else if (chunk_size == 1 ) {
165
- chunk_size = php_ob_default_buffer_size (TSRMLS_C );
166
132
}
167
- if (!block_size )
168
- block_size = chunk_size ;
169
- if (!initial_size )
170
- initial_size = block_size ;
171
133
return php_ob_init (initial_size , block_size , output_handler , chunk_size , erase TSRMLS_CC );
172
134
}
173
135
/* }}} */
@@ -366,17 +328,13 @@ PHPAPI void php_end_implicit_flush(TSRMLS_D)
366
328
*/
367
329
PHPAPI void php_ob_set_internal_handler (php_output_handler_func_t internal_output_handler , uint buffer_size , char * handler_name , zend_bool erase TSRMLS_DC )
368
330
{
369
- if (buffer_size < 2 ) {
370
- buffer_size = php_ob_default_buffer_size (TSRMLS_C );
371
- }
372
331
if (OG (ob_nesting_level )== 0 || OG (active_ob_buffer ).internal_output_handler || strcmp (OG (active_ob_buffer ).handler_name , OB_DEFAULT_HANDLER_NAME )) {
373
332
php_start_ob_buffer (NULL , buffer_size , erase TSRMLS_CC );
374
333
}
375
334
376
335
OG (active_ob_buffer ).internal_output_handler = internal_output_handler ;
377
336
OG (active_ob_buffer ).internal_output_handler_buffer = (char * ) emalloc (buffer_size );
378
337
OG (active_ob_buffer ).internal_output_handler_buffer_size = buffer_size ;
379
- OG (active_ob_buffer ).chunk_size = buffer_size ;
380
338
if (OG (active_ob_buffer ).handler_name )
381
339
efree (OG (active_ob_buffer ).handler_name );
382
340
OG (active_ob_buffer ).handler_name = estrdup (handler_name );
@@ -432,10 +390,6 @@ static int php_ob_init_named(uint initial_size, uint block_size, char *handler_n
432
390
php_error_docref ("ref.outcontrol" TSRMLS_CC , E_WARNING , "output handler '%s' cannot be used twice" , handler_name );
433
391
return FAILURE ;
434
392
}
435
- if (!handler_gz && SG (headers_sent )) {
436
- php_error_docref ("ref.outcontrol" TSRMLS_CC , E_WARNING , "output handler '%s' cannot be activated - headers already sent" , handler_name );
437
- return FAILURE ;
438
- }
439
393
if (!handler_gz && php_ob_init_conflict (handler_name , "zlib output compression" TSRMLS_CC ))
440
394
return FAILURE ;
441
395
if (!handler_mb && php_ob_init_conflict (handler_name , "ob_iconv_handler" TSRMLS_CC ))
@@ -763,7 +717,7 @@ PHP_FUNCTION(ob_start)
763
717
& chunk_size , & erase ) == FAILURE )
764
718
RETURN_FALSE ;
765
719
766
- if (php_start_ob_buffer_ibc (output_handler , 0 , 0 , chunk_size , erase TSRMLS_CC )== FAILURE ) {
720
+ if (php_start_ob_buffer (output_handler , chunk_size , erase TSRMLS_CC )== FAILURE ) {
767
721
RETURN_FALSE ;
768
722
}
769
723
RETURN_TRUE ;
@@ -904,8 +858,8 @@ static int php_ob_buffer_status(php_ob_buffer *ob_buffer, zval *result)
904
858
else {
905
859
add_assoc_long (elem , "type" , PHP_OUTPUT_HANDLER_USER );
906
860
add_assoc_long (elem , "initial_size" , ob_buffer -> size );
861
+ add_assoc_long (elem , "chunk_size" , ob_buffer -> chunk_size );
907
862
}
908
- add_assoc_long (elem , "chunk_size" , ob_buffer -> chunk_size );
909
863
add_assoc_long (elem , "status" , ob_buffer -> status );
910
864
add_assoc_string (elem , "name" , ob_buffer -> handler_name , 1 );
911
865
add_assoc_bool (elem , "del" , ob_buffer -> erase );
0 commit comments