Skip to content

Commit 714c19f

Browse files
Per discussion on #php.bugs (+1 from at least Derick and Jani), revert double_buffering.
1 parent 73cf316 commit 714c19f

File tree

7 files changed

+15
-96
lines changed

7 files changed

+15
-96
lines changed

NEWS

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ PHP 4 NEWS
3131
. Implemented object signal callback ability by using array($obj, $method)
3232
. Added a restart parameter to pcntl_signal, which allows you to disable
3333
the default of system call restarting
34-
- Added php.ini option "double_buffering" which forces an additional first
35-
output buffer and improved handling of buffer sizes. (Marcus)
3634
- Changed DomNode->next_sibling() and DomNode->previous_sibling() to return
3735
NULL instead of false (W3C specs). (chregu)
3836
- Changed DomNode->insert_before() and DomNode->append_child() to conform to

main/main.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -197,24 +197,6 @@ static PHP_INI_MH(OnUpdateTimeout)
197197
}
198198
/* }}} */
199199

200-
/* {{{ OnUpdateOutputBuffering
201-
*/
202-
static PHP_INI_MH(OnUpdateOutputBuffering)
203-
{
204-
if(!strncasecmp(new_value, "off", sizeof("off"))) {
205-
new_value = "0";
206-
new_value_length = sizeof("0");
207-
} else if(!strncasecmp(new_value, "on", sizeof("on"))) {
208-
new_value = "1";
209-
new_value_length = sizeof("1");
210-
}
211-
OnUpdateInt(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
212-
213-
return SUCCESS;
214-
}
215-
/* }}} */
216-
217-
218200
/* Need to convert to strings and make use of:
219201
* PHP_SAFE_MODE
220202
*
@@ -267,8 +249,7 @@ PHP_INI_BEGIN()
267249
STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_ALL, OnUpdateBool, magic_quotes_gpc, php_core_globals, core_globals)
268250
STD_PHP_INI_BOOLEAN("magic_quotes_runtime", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_runtime, php_core_globals, core_globals)
269251
STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_sybase, php_core_globals, core_globals)
270-
STD_PHP_INI_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateOutputBuffering, output_buffering, php_core_globals, core_globals)
271-
STD_PHP_INI_ENTRY("double_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateOutputBuffering, double_buffering, php_core_globals, core_globals)
252+
STD_PHP_INI_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateInt, output_buffering, php_core_globals, core_globals)
272253
STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateString, output_handler, php_core_globals, core_globals)
273254
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
274255
STD_PHP_INI_BOOLEAN("register_globals", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateBool, register_globals, php_core_globals, core_globals)
@@ -846,7 +827,12 @@ int php_request_startup(TSRMLS_D)
846827
php_start_ob_buffer_named(PG(output_handler), 0, 1 TSRMLS_CC);
847828
}
848829
else if (PG(output_buffering)) {
849-
php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
830+
if (PG(output_buffering)>1) {
831+
php_start_ob_buffer(NULL, PG(output_buffering), 0 TSRMLS_CC);
832+
}
833+
else {
834+
php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
835+
}
850836
}
851837
else if (PG(implicit_flush)) {
852838
php_start_implicit_flush(TSRMLS_C);

main/output.c

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -113,61 +113,23 @@ PHPAPI int php_header_write(const char *str, uint str_length TSRMLS_DC)
113113
}
114114
}
115115

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-
128116
/* {{{ php_start_ob_buffer
129117
* Start output buffering */
130118
PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC)
131119
{
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;
152121

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-
{
157122
if (OG(ob_lock)) {
158123
php_error_docref("ref.outcontrol" TSRMLS_CC, E_ERROR, "Cannot use output buffering in output buffering display handlers");
159124
return FAILURE;
160125
}
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;
162131
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);
166132
}
167-
if (!block_size)
168-
block_size = chunk_size;
169-
if (!initial_size)
170-
initial_size = block_size;
171133
return php_ob_init(initial_size, block_size, output_handler, chunk_size, erase TSRMLS_CC);
172134
}
173135
/* }}} */
@@ -366,17 +328,13 @@ PHPAPI void php_end_implicit_flush(TSRMLS_D)
366328
*/
367329
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)
368330
{
369-
if (buffer_size<2) {
370-
buffer_size = php_ob_default_buffer_size(TSRMLS_C);
371-
}
372331
if (OG(ob_nesting_level)==0 || OG(active_ob_buffer).internal_output_handler || strcmp(OG(active_ob_buffer).handler_name, OB_DEFAULT_HANDLER_NAME)) {
373332
php_start_ob_buffer(NULL, buffer_size, erase TSRMLS_CC);
374333
}
375334

376335
OG(active_ob_buffer).internal_output_handler = internal_output_handler;
377336
OG(active_ob_buffer).internal_output_handler_buffer = (char *) emalloc(buffer_size);
378337
OG(active_ob_buffer).internal_output_handler_buffer_size = buffer_size;
379-
OG(active_ob_buffer).chunk_size = buffer_size;
380338
if (OG(active_ob_buffer).handler_name)
381339
efree(OG(active_ob_buffer).handler_name);
382340
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
432390
php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler '%s' cannot be used twice", handler_name);
433391
return FAILURE;
434392
}
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-
}
439393
if (!handler_gz && php_ob_init_conflict(handler_name, "zlib output compression" TSRMLS_CC))
440394
return FAILURE;
441395
if (!handler_mb && php_ob_init_conflict(handler_name, "ob_iconv_handler" TSRMLS_CC))
@@ -763,7 +717,7 @@ PHP_FUNCTION(ob_start)
763717
&chunk_size, &erase) == FAILURE)
764718
RETURN_FALSE;
765719

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) {
767721
RETURN_FALSE;
768722
}
769723
RETURN_TRUE;
@@ -904,8 +858,8 @@ static int php_ob_buffer_status(php_ob_buffer *ob_buffer, zval *result)
904858
else {
905859
add_assoc_long(elem, "type", PHP_OUTPUT_HANDLER_USER);
906860
add_assoc_long(elem, "initial_size", ob_buffer->size);
861+
add_assoc_long(elem, "chunk_size", ob_buffer->chunk_size);
907862
}
908-
add_assoc_long(elem, "chunk_size", ob_buffer->chunk_size);
909863
add_assoc_long(elem, "status", ob_buffer->status);
910864
add_assoc_string(elem, "name", ob_buffer->handler_name, 1);
911865
add_assoc_bool(elem, "del", ob_buffer->erase);

main/php_globals.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ struct _php_core_globals {
5858
zend_bool implicit_flush;
5959

6060
int output_buffering;
61-
int double_buffering;
6261

6362
char *safe_mode_include_dir;
6463
zend_bool safe_mode_gid;

main/php_output.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ PHPAPI int php_body_write(const char *str, uint str_length TSRMLS_DC);
3131
PHPAPI int php_header_write(const char *str, uint str_length TSRMLS_DC);
3232
PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC);
3333
PHPAPI int php_start_ob_buffer_named(const char *output_handler_name, uint chunk_size, zend_bool erase TSRMLS_DC);
34-
PHPAPI int php_start_ob_buffer_ibc(zval *output_handler, uint initial_size, uint block_size, uint chunk_size, zend_bool erase TSRMLS_DC);
3534
PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC);
3635
PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC);
3736
PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
@@ -42,7 +41,6 @@ PHPAPI char *php_get_output_start_filename(TSRMLS_D);
4241
PHPAPI int php_get_output_start_lineno(TSRMLS_D);
4342
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);
4443
PHPAPI int php_ob_handler_used(char *handler_name TSRMLS_DC);
45-
PHPAPI int php_ob_default_buffer_size(TSRMLS_D);
4644

4745
PHP_FUNCTION(ob_start);
4846
PHP_FUNCTION(ob_flush);

php.ini-dist

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ output_buffering = Off
100100
; and you cannot use both "ob_gzhandler" and "zlib.output_compression".
101101
;output_handler =
102102

103-
; Normally you won't use an additional first output buffer when using any
104-
; special output handler but you can enforce this since it can help to reduce
105-
; memory used by output buffering when huge output chunks and total server
106-
; throughput are preferred. This value can either be set 'On' in which case the
107-
; additional buffer is four times the size of all other output buffers or any
108-
; greater size.
109-
;double_buffering = Off
110-
111103
; Transparent output compression using the zlib library
112104
; Valid values for this option are 'off', 'on', or a specific buffer size
113105
; to be used for compression (default is 4KB)

php.ini-recommended

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ output_buffering = 4096
113113
; and you cannot use both "ob_gzhandler" and "zlib.output_compression".
114114
;output_handler =
115115

116-
; Normally you won't use an additional first output buffer when using any
117-
; special output handler but you can enforce this since it can help to reduce
118-
; memory used by output buffering when huge output chunks and total server
119-
; throughput are preferred. This value can either be set 'On' in which case the
120-
; additional buffer is four times the size of all other output buffers or any
121-
; greater size.
122-
;double_buffering = Off
123-
124116
; Transparent output compression using the zlib library
125117
; Valid values for this option are 'off', 'on', or a specific buffer size
126118
; to be used for compression (default is 4KB)

0 commit comments

Comments
 (0)