@@ -432,9 +432,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ob_zstd_handler, 0, 0, 2)
432432 ZEND_ARG_INFO (0 , flags )
433433ZEND_END_ARG_INFO ()
434434#endif
435+ #endif
435436
436437ZEND_DECLARE_MODULE_GLOBALS (zstd );
437- #endif
438438
439439#ifndef Z_PARAM_STR_OR_NULL
440440#define Z_PARAM_STR_OR_NULL (dest ) Z_PARAM_STR_EX(dest, 1, 0)
@@ -1182,6 +1182,11 @@ static int APC_SERIALIZER_NAME(zstd)(APC_SERIALIZER_ARGS)
11821182 php_serialize_data_t var_hash ;
11831183 size_t size ;
11841184 smart_str var = {0 };
1185+ int level = PHP_ZSTD_G (apcu_compression_level );
1186+
1187+ if (!zstd_check_compress_level (level ) || level == 0 ) {
1188+ level = ZSTD_CLEVEL_DEFAULT ;
1189+ }
11851190
11861191 PHP_VAR_SERIALIZE_INIT (var_hash );
11871192 php_var_serialize (& var , (zval * ) value , & var_hash );
@@ -1194,7 +1199,7 @@ static int APC_SERIALIZER_NAME(zstd)(APC_SERIALIZER_ARGS)
11941199 * buf = emalloc (size + 1 );
11951200
11961201 * buf_len = ZSTD_compress (* buf , size , ZSTR_VAL (var .s ), ZSTR_LEN (var .s ),
1197- ZSTD_CLEVEL_DEFAULT );
1202+ level );
11981203 if (ZSTD_isError (* buf_len ) || * buf_len == 0 ) {
11991204 efree (* buf );
12001205 * buf = NULL ;
@@ -1716,24 +1721,32 @@ static PHP_INI_MH(OnUpdate_zstd_output_compression)
17161721
17171722 return SUCCESS ;
17181723}
1724+ #endif
17191725
17201726#define STRINGIFY (n ) #n
17211727#define TOSTRING (n ) STRINGIFY(n)
17221728
17231729PHP_INI_BEGIN ()
1724- STD_PHP_INI_BOOLEAN ("zstd.output_compression" , "0" ,
1730+ #if PHP_VERSION_ID >= 80000
1731+ STD_PHP_INI_BOOLEAN ("zstd.output_compression" , "0" ,
17251732 PHP_INI_ALL , OnUpdate_zstd_output_compression ,
17261733 output_compression_default ,
17271734 zend_zstd_globals , zstd_globals )
1728- STD_PHP_INI_ENTRY ("zstd.output_compression_level" ,
1735+ STD_PHP_INI_ENTRY ("zstd.output_compression_level" ,
17291736 TOSTRING (ZSTD_CLEVEL_DEFAULT ),
17301737 PHP_INI_ALL , OnUpdateLong , output_compression_level ,
17311738 zend_zstd_globals , zstd_globals )
1732- STD_PHP_INI_ENTRY ("zstd.output_compression_dict" , "" ,
1739+ STD_PHP_INI_ENTRY ("zstd.output_compression_dict" , "" ,
17331740 PHP_INI_ALL , OnUpdateString , output_compression_dict ,
17341741 zend_zstd_globals , zstd_globals )
1735- PHP_INI_END ()
17361742#endif
1743+ #if defined(HAVE_APCU_SUPPORT )
1744+ STD_PHP_INI_ENTRY ("zstd.apcu_compression_level" ,
1745+ TOSTRING (ZSTD_CLEVEL_DEFAULT ),
1746+ PHP_INI_ALL , OnUpdateLong , apcu_compression_level ,
1747+ zend_zstd_globals , zstd_globals )
1748+ #endif
1749+ PHP_INI_END ()
17371750
17381751ZEND_MINIT_FUNCTION (zstd )
17391752{
@@ -1827,18 +1840,14 @@ ZEND_MINIT_FUNCTION(zstd)
18271840 php_output_handler_conflict_register (
18281841 ZEND_STRL (PHP_ZSTD_OUTPUT_HANDLER_NAME ),
18291842 php_zstd_output_conflict_check );
1830-
1831- REGISTER_INI_ENTRIES ();
18321843#endif
1833-
1844+ REGISTER_INI_ENTRIES ();
18341845 return SUCCESS ;
18351846}
18361847
18371848ZEND_MSHUTDOWN_FUNCTION (zstd )
18381849{
1839- #if PHP_VERSION_ID >= 80000
18401850 UNREGISTER_INI_ENTRIES ();
1841- #endif
18421851 return SUCCESS ;
18431852}
18441853
@@ -1876,22 +1885,19 @@ ZEND_MINFO_FUNCTION(zstd)
18761885 php_info_print_table_row (2 , "APCu serializer ABI" , APC_SERIALIZER_ABI );
18771886#endif
18781887 php_info_print_table_end ();
1879-
1880- #if PHP_VERSION_ID >= 80000
18811888 DISPLAY_INI_ENTRIES ();
1882- #endif
18831889}
18841890
1885- #if PHP_VERSION_ID >= 80000
18861891ZEND_GINIT_FUNCTION (zstd )
18871892{
18881893#if defined(COMPILE_DL_ZSTD ) && defined(ZTS )
18891894 ZEND_TSRMLS_CACHE_UPDATE ();
18901895#endif
1896+ #if PHP_VERSION_ID >= 80000
18911897 zstd_globals -> ob_handler = NULL ;
18921898 zstd_globals -> handler_registered = 0 ;
1893- }
18941899#endif
1900+ }
18951901
18961902static zend_function_entry zstd_functions [] = {
18971903 ZEND_FE (zstd_compress , arginfo_zstd_compress )
@@ -1972,15 +1978,11 @@ zend_module_entry zstd_module_entry = {
19721978 ZEND_RSHUTDOWN (zstd ),
19731979 ZEND_MINFO (zstd ),
19741980 PHP_ZSTD_VERSION ,
1975- #if PHP_VERSION_ID >= 80000
19761981 PHP_MODULE_GLOBALS (zstd ),
19771982 PHP_GINIT (zstd ),
19781983 NULL ,
19791984 NULL ,
19801985 STANDARD_MODULE_PROPERTIES_EX
1981- #else
1982- STANDARD_MODULE_PROPERTIES
1983- #endif
19841986};
19851987
19861988#ifdef COMPILE_DL_ZSTD
0 commit comments