Skip to content

Commit 163c0b5

Browse files
committed
Merge branch 'PHP-8.2'
2 parents 03fd405 + 3e362f5 commit 163c0b5

18 files changed

+104
-20
lines changed

Zend/zend_ini.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,3 +876,23 @@ ZEND_API ZEND_INI_MH(OnUpdateStringUnempty) /* {{{ */
876876
return SUCCESS;
877877
}
878878
/* }}} */
879+
880+
ZEND_API ZEND_INI_MH(OnUpdateStr) /* {{{ */
881+
{
882+
zend_string **p = (zend_string **) ZEND_INI_GET_ADDR();
883+
*p = new_value;
884+
return SUCCESS;
885+
}
886+
/* }}} */
887+
888+
ZEND_API ZEND_INI_MH(OnUpdateStrNotEmpty) /* {{{ */
889+
{
890+
if (new_value && ZSTR_LEN(new_value) == 0) {
891+
return FAILURE;
892+
}
893+
894+
zend_string **p = (zend_string **) ZEND_INI_GET_ADDR();
895+
*p = new_value;
896+
return SUCCESS;
897+
}
898+
/* }}} */

Zend/zend_ini.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,12 @@ ZEND_API ZEND_INI_MH(OnUpdateBool);
209209
ZEND_API ZEND_INI_MH(OnUpdateLong);
210210
ZEND_API ZEND_INI_MH(OnUpdateLongGEZero);
211211
ZEND_API ZEND_INI_MH(OnUpdateReal);
212+
/* char* versions */
212213
ZEND_API ZEND_INI_MH(OnUpdateString);
213214
ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
215+
/* zend_string* versions */
216+
ZEND_API ZEND_INI_MH(OnUpdateStr);
217+
ZEND_API ZEND_INI_MH(OnUpdateStrNotEmpty);
214218
END_EXTERN_C()
215219

216220
#define ZEND_INI_DISPLAY_ORIG 1

ext/dl_test/dl_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ static const zend_function_entry php_dl_test_use_register_functions_directly_fun
7171

7272
/* {{{ INI */
7373
PHP_INI_BEGIN()
74-
STD_PHP_INI_BOOLEAN("dl_test.long", "0", PHP_INI_ALL, OnUpdateLong, long_value, zend_dl_test_globals, dl_test_globals)
75-
STD_PHP_INI_ENTRY("dl_test.string", "hello", PHP_INI_ALL, OnUpdateString, string_value, zend_dl_test_globals, dl_test_globals)
74+
STD_PHP_INI_ENTRY("dl_test.long", "0", PHP_INI_ALL, OnUpdateLong, long_value, zend_dl_test_globals, dl_test_globals)
75+
STD_PHP_INI_ENTRY("dl_test.string", "hello", PHP_INI_ALL, OnUpdateString, string_value, zend_dl_test_globals, dl_test_globals)
7676
PHP_INI_END()
7777
/* }}} */
7878

ext/ffi/ffi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5179,7 +5179,7 @@ static ZEND_INI_DISP(zend_ffi_enable_displayer_cb) /* {{{ */
51795179
/* }}} */
51805180

51815181
ZEND_INI_BEGIN()
5182-
ZEND_INI_ENTRY3_EX("ffi.enable", "preload", ZEND_INI_SYSTEM, OnUpdateFFIEnable, NULL, NULL, NULL, zend_ffi_enable_displayer_cb)
5182+
ZEND_INI_ENTRY_EX("ffi.enable", "preload", ZEND_INI_SYSTEM, OnUpdateFFIEnable, zend_ffi_enable_displayer_cb)
51835183
STD_ZEND_INI_ENTRY("ffi.preload", NULL, ZEND_INI_SYSTEM, OnUpdateString, preload, zend_ffi_globals, ffi_globals)
51845184
ZEND_INI_END()
51855185

ext/gd/gd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ ZEND_GET_MODULE(gd)
307307

308308
/* {{{ PHP_INI_BEGIN */
309309
PHP_INI_BEGIN()
310-
PHP_INI_ENTRY("gd.jpeg_ignore_warning", "1", PHP_INI_ALL, NULL)
310+
PHP_INI_ENTRY_EX("gd.jpeg_ignore_warning", "1", PHP_INI_ALL, NULL, zend_ini_boolean_displayer_cb)
311311
PHP_INI_END()
312312
/* }}} */
313313

ext/mysqli/mysqli.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static const MYSQLND_REVERSE_API mysqli_reverse_api = {
430430
PHP_INI_BEGIN()
431431
STD_PHP_INI_ENTRY_EX("mysqli.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_mysqli_globals, mysqli_globals, display_link_numbers)
432432
STD_PHP_INI_ENTRY_EX("mysqli.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_persistent, zend_mysqli_globals, mysqli_globals, display_link_numbers)
433-
STD_PHP_INI_BOOLEAN("mysqli.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateLong, allow_persistent, zend_mysqli_globals, mysqli_globals)
433+
STD_PHP_INI_BOOLEAN("mysqli.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_persistent, zend_mysqli_globals, mysqli_globals)
434434
STD_PHP_INI_BOOLEAN("mysqli.rollback_on_cached_plink", "0",PHP_INI_SYSTEM, OnUpdateBool, rollback_on_cached_plink, zend_mysqli_globals, mysqli_globals)
435435
STD_PHP_INI_ENTRY("mysqli.default_host", NULL, PHP_INI_ALL, OnUpdateString, default_host, zend_mysqli_globals, mysqli_globals)
436436
STD_PHP_INI_ENTRY("mysqli.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, zend_mysqli_globals, mysqli_globals)
@@ -441,7 +441,7 @@ PHP_INI_BEGIN()
441441
#else
442442
STD_PHP_INI_ENTRY("mysqli.default_socket", NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_socket, zend_mysqli_globals, mysqli_globals)
443443
#endif
444-
STD_PHP_INI_BOOLEAN("mysqli.allow_local_infile", "0", PHP_INI_SYSTEM, OnUpdateLong, allow_local_infile, zend_mysqli_globals, mysqli_globals)
444+
STD_PHP_INI_BOOLEAN("mysqli.allow_local_infile", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_local_infile, zend_mysqli_globals, mysqli_globals)
445445
STD_PHP_INI_ENTRY("mysqli.local_infile_directory", NULL, PHP_INI_SYSTEM, OnUpdateString, local_infile_directory, zend_mysqli_globals, mysqli_globals)
446446
PHP_INI_END()
447447
/* }}} */

ext/mysqli/php_mysqli_structs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqli)
241241
zend_long num_active_persistent;
242242
zend_long num_inactive_persistent;
243243
zend_long max_persistent;
244-
zend_long allow_persistent;
244+
bool allow_persistent;
245245
zend_ulong default_port;
246246
char *default_host;
247247
char *default_user;
248248
char *default_pw;
249249
char *default_socket;
250-
zend_long allow_local_infile;
250+
bool allow_local_infile;
251251
char *local_infile_directory;
252252
zend_long error_no;
253253
char *error_msg;

ext/odbc/php_odbc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static PHP_INI_DISP(display_cursortype)
349349

350350
/* {{{ PHP_INI_BEGIN */
351351
PHP_INI_BEGIN()
352-
STD_PHP_INI_BOOLEAN("odbc.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateLong,
352+
STD_PHP_INI_BOOLEAN("odbc.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool,
353353
allow_persistent, zend_odbc_globals, odbc_globals)
354354
STD_PHP_INI_ENTRY_EX("odbc.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateLong,
355355
max_persistent, zend_odbc_globals, odbc_globals, display_link_nums)
@@ -365,7 +365,7 @@ PHP_INI_BEGIN()
365365
defaultlrl, zend_odbc_globals, odbc_globals, display_lrl)
366366
STD_PHP_INI_ENTRY_EX("odbc.defaultbinmode", "1", PHP_INI_ALL, OnUpdateLong,
367367
defaultbinmode, zend_odbc_globals, odbc_globals, display_binmode)
368-
STD_PHP_INI_BOOLEAN("odbc.check_persistent", "1", PHP_INI_SYSTEM, OnUpdateLong,
368+
STD_PHP_INI_BOOLEAN("odbc.check_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool,
369369
check_persistent, zend_odbc_globals, odbc_globals)
370370
STD_PHP_INI_ENTRY_EX("odbc.default_cursortype", "3", PHP_INI_ALL, OnUpdateLong,
371371
default_cursortype, zend_odbc_globals, odbc_globals, display_cursortype)

ext/odbc/php_odbc_includes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ ZEND_BEGIN_MODULE_GLOBALS(odbc)
228228
char *defDB;
229229
char *defUser;
230230
char *defPW;
231-
zend_long allow_persistent;
232-
zend_long check_persistent;
231+
bool allow_persistent;
232+
bool check_persistent;
233233
zend_long max_persistent;
234234
zend_long max_links;
235235
zend_long num_persistent;

ext/pcre/php_pcre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ PHP_INI_BEGIN()
369369
STD_PHP_INI_ENTRY("pcre.backtrack_limit", "1000000", PHP_INI_ALL, OnUpdateBacktrackLimit, backtrack_limit, zend_pcre_globals, pcre_globals)
370370
STD_PHP_INI_ENTRY("pcre.recursion_limit", "100000", PHP_INI_ALL, OnUpdateRecursionLimit, recursion_limit, zend_pcre_globals, pcre_globals)
371371
#ifdef HAVE_PCRE_JIT_SUPPORT
372-
STD_PHP_INI_ENTRY("pcre.jit", "1", PHP_INI_ALL, OnUpdateJit, jit, zend_pcre_globals, pcre_globals)
372+
STD_PHP_INI_BOOLEAN("pcre.jit", "1", PHP_INI_ALL, OnUpdateJit, jit, zend_pcre_globals, pcre_globals)
373373
#endif
374374
PHP_INI_END()
375375

ext/session/session.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,12 @@ PHP_INI_BEGIN()
782782
STD_PHP_INI_ENTRY("session.cookie_lifetime", "0", PHP_INI_ALL, OnUpdateCookieLifetime,cookie_lifetime, php_ps_globals, ps_globals)
783783
STD_PHP_INI_ENTRY("session.cookie_path", "/", PHP_INI_ALL, OnUpdateSessionString, cookie_path, php_ps_globals, ps_globals)
784784
STD_PHP_INI_ENTRY("session.cookie_domain", "", PHP_INI_ALL, OnUpdateSessionString, cookie_domain, php_ps_globals, ps_globals)
785-
STD_PHP_INI_ENTRY("session.cookie_secure", "0", PHP_INI_ALL, OnUpdateSessionBool, cookie_secure, php_ps_globals, ps_globals)
786-
STD_PHP_INI_ENTRY("session.cookie_httponly", "0", PHP_INI_ALL, OnUpdateSessionBool, cookie_httponly, php_ps_globals, ps_globals)
785+
STD_PHP_INI_BOOLEAN("session.cookie_secure", "0", PHP_INI_ALL, OnUpdateSessionBool, cookie_secure, php_ps_globals, ps_globals)
786+
STD_PHP_INI_BOOLEAN("session.cookie_httponly", "0", PHP_INI_ALL, OnUpdateSessionBool, cookie_httponly, php_ps_globals, ps_globals)
787787
STD_PHP_INI_ENTRY("session.cookie_samesite", "", PHP_INI_ALL, OnUpdateSessionString, cookie_samesite, php_ps_globals, ps_globals)
788-
STD_PHP_INI_ENTRY("session.use_cookies", "1", PHP_INI_ALL, OnUpdateSessionBool, use_cookies, php_ps_globals, ps_globals)
789-
STD_PHP_INI_ENTRY("session.use_only_cookies", "1", PHP_INI_ALL, OnUpdateSessionBool, use_only_cookies, php_ps_globals, ps_globals)
790-
STD_PHP_INI_ENTRY("session.use_strict_mode", "0", PHP_INI_ALL, OnUpdateSessionBool, use_strict_mode, php_ps_globals, ps_globals)
788+
STD_PHP_INI_BOOLEAN("session.use_cookies", "1", PHP_INI_ALL, OnUpdateSessionBool, use_cookies, php_ps_globals, ps_globals)
789+
STD_PHP_INI_BOOLEAN("session.use_only_cookies", "1", PHP_INI_ALL, OnUpdateSessionBool, use_only_cookies, php_ps_globals, ps_globals)
790+
STD_PHP_INI_BOOLEAN("session.use_strict_mode", "0", PHP_INI_ALL, OnUpdateSessionBool, use_strict_mode, php_ps_globals, ps_globals)
791791
STD_PHP_INI_ENTRY("session.referer_check", "", PHP_INI_ALL, OnUpdateSessionString, extern_referer_chk, php_ps_globals, ps_globals)
792792
STD_PHP_INI_ENTRY("session.cache_limiter", "nocache", PHP_INI_ALL, OnUpdateSessionString, cache_limiter, php_ps_globals, ps_globals)
793793
STD_PHP_INI_ENTRY("session.cache_expire", "180", PHP_INI_ALL, OnUpdateSessionLong, cache_expire, php_ps_globals, ps_globals)

ext/tidy/tidy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ ZEND_DECLARE_MODULE_GLOBALS(tidy)
168168

169169
PHP_INI_BEGIN()
170170
STD_PHP_INI_ENTRY("tidy.default_config", "", PHP_INI_SYSTEM, OnUpdateString, default_config, zend_tidy_globals, tidy_globals)
171-
STD_PHP_INI_ENTRY("tidy.clean_output", "0", PHP_INI_USER, php_tidy_set_clean_output, clean_output, zend_tidy_globals, tidy_globals)
171+
STD_PHP_INI_BOOLEAN("tidy.clean_output", "0", PHP_INI_USER, php_tidy_set_clean_output, clean_output, zend_tidy_globals, tidy_globals)
172172
PHP_INI_END()
173173

174174
static zend_class_entry *tidy_ce_doc, *tidy_ce_node;

ext/zend_test/php_test.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ ZEND_BEGIN_MODULE_GLOBALS(zend_test)
5555
bool print_stderr_mshutdown;
5656
zend_test_fiber *active_fiber;
5757
zend_long quantity_value;
58+
zend_string *str_test;
59+
zend_string *not_empty_str_test;
5860
ZEND_END_MODULE_GLOBALS(zend_test)
5961

6062
extern ZEND_DECLARE_MODULE_GLOBALS(zend_test)

ext/zend_test/test.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ static ZEND_FUNCTION(zend_test_zend_ini_parse_uquantity)
415415
}
416416
}
417417

418+
static ZEND_FUNCTION(zend_test_zend_ini_str)
419+
{
420+
ZEND_PARSE_PARAMETERS_NONE();
421+
422+
RETURN_STR(ZT_G(str_test));
423+
}
424+
418425
static ZEND_FUNCTION(ZendTestNS2_namespaced_func)
419426
{
420427
ZEND_PARSE_PARAMETERS_NONE();
@@ -632,6 +639,8 @@ PHP_INI_BEGIN()
632639
STD_PHP_INI_BOOLEAN("zend_test.register_passes", "0", PHP_INI_SYSTEM, OnUpdateBool, register_passes, zend_zend_test_globals, zend_test_globals)
633640
STD_PHP_INI_BOOLEAN("zend_test.print_stderr_mshutdown", "0", PHP_INI_SYSTEM, OnUpdateBool, print_stderr_mshutdown, zend_zend_test_globals, zend_test_globals)
634641
STD_PHP_INI_ENTRY("zend_test.quantity_value", "0", PHP_INI_ALL, OnUpdateLong, quantity_value, zend_zend_test_globals, zend_test_globals)
642+
STD_PHP_INI_ENTRY("zend_test.str_test", "", PHP_INI_ALL, OnUpdateStr, str_test, zend_zend_test_globals, zend_test_globals)
643+
STD_PHP_INI_ENTRY("zend_test.not_empty_str_test", "val", PHP_INI_ALL, OnUpdateStrNotEmpty, not_empty_str_test, zend_zend_test_globals, zend_test_globals)
635644
PHP_INI_END()
636645

637646
void (*old_zend_execute_ex)(zend_execute_data *execute_data);

ext/zend_test/test.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ function zend_call_method(object|string $obj_or_class, string $method, mixed $ar
152152

153153
function zend_test_zend_ini_parse_quantity(string $str): int {}
154154
function zend_test_zend_ini_parse_uquantity(string $str): int {}
155+
156+
function zend_test_zend_ini_str(): string {}
155157
}
156158

157159
namespace ZendTestNS {

ext/zend_test/test_arginfo.h

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Test OnUpdateStr and OnUpdateStrNotEmpty validators.
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
echo 'str_test INI', PHP_EOL;
8+
var_dump(ini_get("zend_test.str_test"));
9+
var_dump(ini_set("zend_test.str_test", "Test"));
10+
var_dump(ini_get("zend_test.str_test"));
11+
var_dump(ini_set("zend_test.str_test", ""));
12+
var_dump(ini_get("zend_test.str_test"));
13+
14+
echo 'not_empty_str_test INI', PHP_EOL;
15+
var_dump(ini_get("zend_test.not_empty_str_test"));
16+
var_dump(ini_set("zend_test.not_empty_str_test", "Test"));
17+
var_dump(ini_get("zend_test.not_empty_str_test"));
18+
var_dump(ini_set("zend_test.not_empty_str_test", ""));
19+
var_dump(ini_get("zend_test.not_empty_str_test"));
20+
?>
21+
--EXPECT--
22+
str_test INI
23+
string(0) ""
24+
string(0) ""
25+
string(4) "Test"
26+
string(4) "Test"
27+
string(0) ""
28+
not_empty_str_test INI
29+
string(3) "val"
30+
string(3) "val"
31+
string(4) "Test"
32+
bool(false)
33+
string(4) "Test"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Test zend_test_zend_ini_str() to check for GC refcount on global returned
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
var_dump(zend_test_zend_ini_str());
8+
?>
9+
--EXPECT--
10+
string(0) ""

0 commit comments

Comments
 (0)