Hi: the fix is bad smell, I knew. maybe you can find a better fix :) ? the problem is explained in #55544: " here is the confusion(assuming -d output_handler=ob_gzhandler -d zlib.output_compression=0) :
1. php.output_handler will change the ZLIGB(output_compression) before the zlib RINIT 2. in zlib RINIT, we set the ZLIBG(output_compression) to default value(ini) 3. if we don't override the ZLIBG(output_compression), then in the php_zlib_output_compression_start which will be called in RINT will try to start zlib compression handler (although it depends on the requeset header), then, the conflict warning will be threw. 4. if we override it, then it the php_zlib_output_compression_start, it will return FALIURE, and no compression occurred(see the codes from my previous reply) so, the key problem is multi-featrues depends on one global flag -> ZLIBG(output_compression)." thanks On Tue, Jul 24, 2012 at 2:43 PM, Xinchen Hui <larue...@php.net> wrote: > Commit: 4c1e2bbd6f744b4048d4e0540ecc5dbe005494fe > Author: Xinchen Hui <larue...@php.net> Tue, 24 Jul 2012 14:43:53 > +0800 > Parents: 2abc4c2f6fabfc81d12380170dc5ec7be9314a61 > Branches: PHP-5.4 > > Link: > http://git.php.net/?p=php-src.git;a=commitdiff;h=4c1e2bbd6f744b4048d4e0540ecc5dbe005494fe > > Log: > Re-fix bug #55544 > > Bugs: > https://bugs.php.net/55544 > > Changed paths: > M ext/zlib/php_zlib.h > A ext/zlib/tests/bug55544.phpt > M ext/zlib/zlib.c > > > Diff: > diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h > index 449dfed..ab67351 100644 > --- a/ext/zlib/php_zlib.h > +++ b/ext/zlib/php_zlib.h > @@ -55,6 +55,7 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib) > long output_compression_default; > char *output_handler; > php_zlib_context *ob_gzhandler; > + zend_bool handler_registered; > ZEND_END_MODULE_GLOBALS(zlib); > > php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char > *mode, int options, char **opened_path, php_stream_context *context > STREAMS_DC TSRMLS_DC); > diff --git a/ext/zlib/tests/bug55544.phpt b/ext/zlib/tests/bug55544.phpt > new file mode 100644 > index 0000000..ca4214a > Binary files /dev/null and b/ext/zlib/tests/bug55544.phpt differ > diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c > index eac757b..7ff2b30 100644 > --- a/ext/zlib/zlib.c > +++ b/ext/zlib/zlib.c > @@ -263,6 +263,8 @@ static php_output_handler > *php_zlib_output_handler_init(const char *handler_name > ZLIBG(output_compression) = chunk_size ? chunk_size : > PHP_OUTPUT_HANDLER_DEFAULT_SIZE; > } > > + ZLIBG(handler_registered) = 1; > + > if ((h = php_output_handler_create_internal(handler_name, > handler_name_len, php_zlib_output_handler, chunk_size, flags TSRMLS_CC))) { > php_output_handler_set_context(h, > php_zlib_output_handler_context_init(TSRMLS_C), > php_zlib_output_handler_context_dtor TSRMLS_CC); > } > @@ -964,9 +966,10 @@ static PHP_MSHUTDOWN_FUNCTION(zlib) > static PHP_RINIT_FUNCTION(zlib) > { > ZLIBG(compression_coding) = 0; > - ZLIBG(output_compression) = ZLIBG(output_compression_default); > - > - php_zlib_output_compression_start(TSRMLS_C); > + if (!ZLIBG(handler_registered)) { > + ZLIBG(output_compression) = ZLIBG(output_compression_default); > + php_zlib_output_compression_start(TSRMLS_C); > + } > > return SUCCESS; > } > @@ -976,6 +979,7 @@ static PHP_RINIT_FUNCTION(zlib) > static PHP_RSHUTDOWN_FUNCTION(zlib) > { > php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_C); > + ZLIBG(handler_registered) = 0; > > return SUCCESS; > } > @@ -1000,6 +1004,7 @@ static PHP_MINFO_FUNCTION(zlib) > static ZEND_MODULE_GLOBALS_CTOR_D(zlib) > { > zlib_globals->ob_gzhandler = NULL; > + zlib_globals->handler_registered = 0; > } > /* }}} */ > > > -- > PHP CVS Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Laruence Xinchen Hui http://www.laruence.com/ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php