Skip to content

Commit e077c6b

Browse files
committed
Make it possible to enable chunked output buffering without providing
an output handling function
1 parent 2aca8c6 commit e077c6b

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

main/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ PHP_INI_BEGIN()
227227
STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_ALL, OnUpdateBool, magic_quotes_gpc, php_core_globals, core_globals)
228228
STD_PHP_INI_BOOLEAN("magic_quotes_runtime", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_runtime, php_core_globals, core_globals)
229229
STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_sybase, php_core_globals, core_globals)
230-
STD_PHP_INI_BOOLEAN("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateBool, output_buffering, php_core_globals, core_globals)
230+
STD_PHP_INI_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateInt, output_buffering, php_core_globals, core_globals)
231231
STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateString, output_handler, php_core_globals, core_globals)
232232
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_ALL, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
233233
STD_PHP_INI_BOOLEAN("register_globals", "1", PHP_INI_ALL, OnUpdateBool, register_globals, php_core_globals, core_globals)
@@ -669,7 +669,11 @@ int php_request_startup(TSRMLS_D)
669669
Z_TYPE_P(output_handler) = IS_STRING;
670670
php_start_ob_buffer(output_handler, 0 TSRMLS_CC);
671671
} else if (PG(output_buffering)) {
672-
php_start_ob_buffer(NULL, 0 TSRMLS_CC);
672+
if (PG(output_buffering)>1) {
673+
php_start_ob_buffer(NULL, PG(output_buffering) TSRMLS_CC);
674+
} else {
675+
php_start_ob_buffer(NULL, 0 TSRMLS_CC);
676+
}
673677
} else if (PG(implicit_flush)) {
674678
php_start_implicit_flush(TSRMLS_C);
675679
}

main/output.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,11 @@ static int php_ub_body_write(const char *str, uint str_length TSRMLS_DC)
482482
Turn on Output Buffering (specifying an optional output handler). */
483483
PHP_FUNCTION(ob_start)
484484
{
485-
zval *output_handler;
485+
zval *output_handler=NULL;
486486
uint chunk_size=0;
487487

488488
switch (ZEND_NUM_ARGS()) {
489489
case 0:
490-
output_handler = NULL;
491490
break;
492491
case 1: {
493492
zval **output_handler_p;
@@ -506,9 +505,11 @@ PHP_FUNCTION(ob_start)
506505
if (zend_get_parameters_ex(2, &output_handler_p, &chunk_size_p)==FAILURE) {
507506
RETURN_FALSE;
508507
}
509-
SEPARATE_ZVAL(output_handler_p);
510-
output_handler = *output_handler_p;
511-
output_handler->refcount++;
508+
if (Z_STRLEN_PP(output_handler_p)>0) {
509+
SEPARATE_ZVAL(output_handler_p);
510+
output_handler = *output_handler_p;
511+
output_handler->refcount++;
512+
}
512513
convert_to_long_ex(chunk_size_p);
513514
chunk_size = (uint) Z_LVAL_PP(chunk_size_p);
514515
}

main/php_globals.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ struct _php_core_globals {
5252
zend_bool magic_quotes_runtime;
5353
zend_bool magic_quotes_sybase;
5454

55+
zend_bool safe_mode;
56+
5557
zend_bool allow_call_time_pass_reference;
56-
zend_bool zend_set_utility_values;
57-
zend_bool output_buffering;
5858
zend_bool implicit_flush;
5959

60-
zend_bool safe_mode;
60+
int output_buffering;
61+
6162
char *safe_mode_include_dir;
6263
zend_bool safe_mode_gid;
6364
zend_bool sql_safe_mode;

0 commit comments

Comments
 (0)