Skip to content

Commit 0ad53bf

Browse files
committed
fix bug #60761 zlib.output_compression fails on refresh
1 parent d9788dd commit 0ad53bf

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

ext/zlib/zlib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ static void php_zlib_output_compression_start(TSRMLS_D)
284284
ZLIBG(output_compression) = PHP_OUTPUT_HANDLER_DEFAULT_SIZE;
285285
/* break omitted intentionally */
286286
default:
287-
if ( (h = php_zlib_output_handler_init(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME), ZLIBG(output_compression), PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC)) &&
287+
if ( php_zlib_output_encoding(TSRMLS_C) &&
288+
(h = php_zlib_output_handler_init(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME), ZLIBG(output_compression), PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC)) &&
288289
(SUCCESS == php_output_handler_start(h TSRMLS_CC))) {
289290
if (ZLIBG(output_handler) && *ZLIBG(output_handler)) {
290291
MAKE_STD_ZVAL(zoh);
@@ -966,7 +967,6 @@ static PHP_RINIT_FUNCTION(zlib)
966967

967968
static PHP_RSHUTDOWN_FUNCTION(zlib)
968969
{
969-
ZLIBG(output_compression) = 0;
970970
php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_C);
971971

972972
return SUCCESS;

main/output.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
10251025
case PHP_OUTPUT_HANDLER_SUCCESS:
10261026
/* no more buffered data */
10271027
handler->buffer.used = 0;
1028+
handler->flags |= PHP_OUTPUT_HANDLER_PROCESSED;
10281029
break;
10291030
}
10301031

main/php_output.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
/* handler status flags */
4646
#define PHP_OUTPUT_HANDLER_STARTED 0x1000
4747
#define PHP_OUTPUT_HANDLER_DISABLED 0x2000
48+
#define PHP_OUTPUT_HANDLER_PROCESSED 0x4000
4849

4950
/* handler op return values */
5051
typedef enum _php_output_handler_status_t {
@@ -82,7 +83,7 @@ typedef enum _php_output_handler_hook_t {
8283
} php_output_handler_hook_t;
8384

8485
#define PHP_OUTPUT_HANDLER_INITBUF_SIZE(s) \
85-
( (s) ? \
86+
( ((s) > 1) ? \
8687
(s) + PHP_OUTPUT_HANDLER_ALIGNTO_SIZE - ((s) % (PHP_OUTPUT_HANDLER_ALIGNTO_SIZE)) : \
8788
PHP_OUTPUT_HANDLER_DEFAULT_SIZE \
8889
)

0 commit comments

Comments
 (0)