Skip to content

Commit

Permalink
Drop PHP 5 support by removing conditions from output handler
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubOnderka committed Jan 31, 2024
1 parent 5142edb commit 1080e1e
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions brotli.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ static int php_brotli_decoder_create(BrotliDecoderState **decoder)
return SUCCESS;
}

#if PHP_VERSION_ID >= 70000
static php_brotli_state_context* php_brotli_state_init(void)
{
php_brotli_state_context *ctx
Expand Down Expand Up @@ -171,26 +170,17 @@ static void php_brotli_state_rsrc_dtor(zend_resource *res)
php_brotli_state_context *ctx = zend_fetch_resource(res, NULL, le_state);
php_brotli_state_destroy(ctx);
}
#endif

#if PHP_VERSION_ID > 50400 // Output Handler: 5.4+

#define PHP_BROTLI_OUTPUT_HANDLER "ob_brotli_handler"

static int php_brotli_output_encoding(void)
{
#if PHP_MAJOR_VERSION >= 7
#if defined(COMPILE_DL_BROTLI) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
zval *enc;
#else
zval **enc;
TSRMLS_FETCH();
#endif

if (!BROTLI_G(compression_coding)) {
#if PHP_MAJOR_VERSION >= 7
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY
|| zend_is_auto_global_str(ZEND_STRL("_SERVER")))
&& (enc = zend_hash_str_find(
Expand All @@ -202,16 +192,6 @@ static int php_brotli_output_encoding(void)
BROTLI_G(compression_coding) = 1;
}
}
#else
if ((PG(http_globals)[TRACK_VARS_SERVER]
|| zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC)) &&
SUCCESS == zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING"), (void *) &enc)) {
convert_to_string(*enc);
if (strstr(Z_STRVAL_PP(enc), "br")) {
BROTLI_G(compression_coding) = 1;
}
}
#endif
}

return BROTLI_G(compression_coding);
Expand Down Expand Up @@ -255,9 +235,7 @@ static int php_brotli_output_handler(void **handler_context,
return FAILURE;
}

#if PHP_VERSION_ID > 50400
quality = BROTLI_G(output_compression_level);
#endif
if (quality < BROTLI_MIN_QUALITY || quality > BROTLI_MAX_QUALITY) {
quality = BROTLI_DEFAULT_QUALITY;
}
Expand Down Expand Up @@ -449,7 +427,6 @@ static PHP_INI_MH(OnUpdate_brotli_output_compression)
return FAILURE;
}

#if PHP_MAJOR_VERSION >= 7
if (!strncasecmp(ZSTR_VAL(new_value), "off", sizeof("off"))) {
int_value = 0;
} else if (!strncasecmp(ZSTR_VAL(new_value), "on", sizeof("on"))) {
Expand All @@ -463,17 +440,6 @@ static PHP_INI_MH(OnUpdate_brotli_output_compression)
} else {
int_value = 0;
}
#else
if (!strncasecmp(new_value, "off", sizeof("off"))) {
int_value = 0;
} else if (!strncasecmp(new_value, "on", sizeof("on"))) {
int_value = 1;
} else if (zend_atoi(new_value, new_value_length)) {
int_value = 1;
} else {
int_value = 0;
}
#endif

if (stage == PHP_INI_STAGE_RUNTIME) {
status = php_output_get_status(TSRMLS_C);
Expand Down Expand Up @@ -528,7 +494,6 @@ static void php_brotli_init_globals(zend_brotli_globals *brotli_globals)
brotli_globals->compression_coding = 0;
brotli_globals->ob_handler = NULL;
}
#endif

typedef struct _php_brotli_stream_data {
BrotliEncoderState *cctx;
Expand Down

0 comments on commit 1080e1e

Please sign in to comment.