Skip to content

Commit 7845f73

Browse files
committed
Fix UNKNOWN default values in ext/standard
1 parent f7fbc63 commit 7845f73

29 files changed

+306
-276
lines changed

Zend/zend_API.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,9 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
15111511
#define Z_PARAM_ARRAY_HT(dest) \
15121512
Z_PARAM_ARRAY_HT_EX(dest, 0, 0)
15131513

1514+
#define Z_PARAM_ARRAY_HT_OR_NULL(dest) \
1515+
Z_PARAM_ARRAY_HT_EX(dest, 1, 0)
1516+
15141517
/* old "H" */
15151518
#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX2(dest, check_null, deref, separate) \
15161519
Z_PARAM_PROLOGUE(deref, separate); \

ext/bz2/bz2.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function bzread($bz, int $length = 1024): string|false {}
1515
* @param resource $bz
1616
* @alias fwrite
1717
*/
18-
function bzwrite($bz, string $str, int $length = UNKNOWN): int|false {}
18+
function bzwrite($bz, string $str, ?int $length = null): int|false {}
1919

2020
/**
2121
* @param resource $bz

ext/bz2/bz2_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: a5c534b7cd92619dfa0fdf29bd0a94fcda27f089 */
2+
* Stub hash: 9bcd75ddbde225e65ee9f00d86d16677d671b4e4 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_bzopen, 0, 0, 2)
55
ZEND_ARG_INFO(0, file)
@@ -14,7 +14,7 @@ ZEND_END_ARG_INFO()
1414
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_bzwrite, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
1515
ZEND_ARG_INFO(0, bz)
1616
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
17-
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
17+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
1818
ZEND_END_ARG_INFO()
1919

2020
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bzflush, 0, 1, _IS_BOOL, 0)

ext/standard/basic_functions.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ PHP_FUNCTION(getenv)
734734

735735
ZEND_PARSE_PARAMETERS_START(0, 2)
736736
Z_PARAM_OPTIONAL
737-
Z_PARAM_STRING(str, str_len)
737+
Z_PARAM_STRING_OR_NULL(str, str_len)
738738
Z_PARAM_BOOL(local_only)
739739
ZEND_PARSE_PARAMETERS_END();
740740

@@ -1424,22 +1424,17 @@ PHP_FUNCTION(error_log)
14241424
{
14251425
char *message, *opt = NULL, *headers = NULL;
14261426
size_t message_len, opt_len = 0, headers_len = 0;
1427-
int opt_err = 0, argc = ZEND_NUM_ARGS();
14281427
zend_long erropt = 0;
14291428

14301429
ZEND_PARSE_PARAMETERS_START(1, 4)
14311430
Z_PARAM_STRING(message, message_len)
14321431
Z_PARAM_OPTIONAL
14331432
Z_PARAM_LONG(erropt)
1434-
Z_PARAM_PATH(opt, opt_len)
1435-
Z_PARAM_STRING(headers, headers_len)
1433+
Z_PARAM_PATH_OR_NULL(opt, opt_len)
1434+
Z_PARAM_STRING_OR_NULL(headers, headers_len)
14361435
ZEND_PARSE_PARAMETERS_END();
14371436

1438-
if (argc > 1) {
1439-
opt_err = (int)erropt;
1440-
}
1441-
1442-
if (_php_error_log_ex(opt_err, message, message_len, opt, headers) == FAILURE) {
1437+
if (_php_error_log_ex((int) erropt, message, message_len, opt, headers) == FAILURE) {
14431438
RETURN_FALSE;
14441439
}
14451440

@@ -2265,16 +2260,17 @@ PHP_FUNCTION(connection_status)
22652260
PHP_FUNCTION(ignore_user_abort)
22662261
{
22672262
zend_bool arg = 0;
2263+
zend_bool arg_is_null = 1;
22682264
int old_setting;
22692265

22702266
ZEND_PARSE_PARAMETERS_START(0, 1)
22712267
Z_PARAM_OPTIONAL
2272-
Z_PARAM_BOOL(arg)
2268+
Z_PARAM_BOOL_OR_NULL(arg, arg_is_null)
22732269
ZEND_PARSE_PARAMETERS_END();
22742270

22752271
old_setting = (unsigned short)PG(ignore_user_abort);
22762272

2277-
if (ZEND_NUM_ARGS()) {
2273+
if (!arg_is_null) {
22782274
zend_string *key = zend_string_init("ignore_user_abort", sizeof("ignore_user_abort") - 1, 0);
22792275
zend_alter_ini_entry_chars(key, arg ? "1" : "0", 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
22802276
zend_string_release_ex(key, 0);

0 commit comments

Comments
 (0)