@@ -263,6 +263,8 @@ static php_output_handler *php_zlib_output_handler_init(const char *handler_name
263263 ZLIBG (output_compression ) = chunk_size ? chunk_size : PHP_OUTPUT_HANDLER_DEFAULT_SIZE ;
264264 }
265265
266+ ZLIBG (handler_registered ) = 1 ;
267+
266268 if ((h = php_output_handler_create_internal (handler_name , handler_name_len , php_zlib_output_handler , chunk_size , flags TSRMLS_CC ))) {
267269 php_output_handler_set_context (h , php_zlib_output_handler_context_init (TSRMLS_C ), php_zlib_output_handler_context_dtor TSRMLS_CC );
268270 }
@@ -964,9 +966,10 @@ static PHP_MSHUTDOWN_FUNCTION(zlib)
964966static PHP_RINIT_FUNCTION (zlib )
965967{
966968 ZLIBG (compression_coding ) = 0 ;
967- ZLIBG (output_compression ) = ZLIBG (output_compression_default );
968-
969- php_zlib_output_compression_start (TSRMLS_C );
969+ if (!ZLIBG (handler_registered )) {
970+ ZLIBG (output_compression ) = ZLIBG (output_compression_default );
971+ php_zlib_output_compression_start (TSRMLS_C );
972+ }
970973
971974 return SUCCESS ;
972975}
@@ -976,6 +979,7 @@ static PHP_RINIT_FUNCTION(zlib)
976979static PHP_RSHUTDOWN_FUNCTION (zlib )
977980{
978981 php_zlib_cleanup_ob_gzhandler_mess (TSRMLS_C );
982+ ZLIBG (handler_registered ) = 0 ;
979983
980984 return SUCCESS ;
981985}
@@ -1000,6 +1004,7 @@ static PHP_MINFO_FUNCTION(zlib)
10001004static ZEND_MODULE_GLOBALS_CTOR_D (zlib )
10011005{
10021006 zlib_globals -> ob_gzhandler = NULL ;
1007+ zlib_globals -> handler_registered = 0 ;
10031008}
10041009/* }}} */
10051010
0 commit comments