From 2293ae49954607ab86d52be3b263df1cf0c7a313 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Fri, 22 Sep 2023 15:04:40 -0300 Subject: [PATCH 1/8] Aggressively use actual func params in verror PHP errors used to not show parameter info consistently. Make it so that it uses a backtrace to get function info, similar to how exceptions work. This makes the docref error functions' parameter argument mostly vestigal, being used only if allocation fails basically. Several tests will fail from the fact we include function params. One annoyance is that _build_trace_args truncates strings according to exception_string_param_max_len. See GH-12048 --- Zend/zend_exceptions.c | 78 ++++++++++++++++++++++++++++++++---------- Zend/zend_exceptions.h | 2 ++ main/main.c | 8 ++++- 3 files changed, 68 insertions(+), 20 deletions(-) diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index d23fb647af9d..04fa77080836 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -542,6 +542,31 @@ static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */ } /* }}} */ +static void _build_trace_args_list(zval *tmp, smart_str *str) /* {{{ */ +{ + if (EXPECTED(Z_TYPE_P(tmp) == IS_ARRAY)) { + size_t last_len = ZSTR_LEN(str->s); + zend_string *name; + zval *arg; + + ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(tmp), name, arg) { + if (name) { + smart_str_append(str, name); + smart_str_appends(str, ": "); + } + _build_trace_args(arg, str); + } ZEND_HASH_FOREACH_END(); + + if (last_len != ZSTR_LEN(str->s)) { + ZSTR_LEN(str->s) -= 2; /* remove last ', ' */ + } + } else { + /* only happens w/ reflection abuse (Zend/tests/bug63762.phpt) */ + zend_error(E_WARNING, "args element is not an array"); + } +} +/* }}} */ + static void _build_trace_string(smart_str *str, const HashTable *ht, uint32_t num) /* {{{ */ { zval *file, *tmp; @@ -588,30 +613,45 @@ static void _build_trace_string(smart_str *str, const HashTable *ht, uint32_t nu smart_str_appendc(str, '('); tmp = zend_hash_find_known_hash(ht, ZSTR_KNOWN(ZEND_STR_ARGS)); if (tmp) { - if (EXPECTED(Z_TYPE_P(tmp) == IS_ARRAY)) { - size_t last_len = ZSTR_LEN(str->s); - zend_string *name; - zval *arg; - - ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(tmp), name, arg) { - if (name) { - smart_str_append(str, name); - smart_str_appends(str, ": "); - } - _build_trace_args(arg, str); - } ZEND_HASH_FOREACH_END(); - - if (last_len != ZSTR_LEN(str->s)) { - ZSTR_LEN(str->s) -= 2; /* remove last ', ' */ - } - } else { - zend_error(E_WARNING, "args element is not an array"); - } + _build_trace_args_list(tmp, str); } smart_str_appends(str, ")\n"); } /* }}} */ +/* {{{ Gets the function arguments printed as a string from a backtrace frame. */ +ZEND_API zend_string *zend_trace_function_args_to_string(const HashTable *frame) { + smart_str str = {0}; + smart_str_appends(&str, ""); + + zval *tmp = zend_hash_find_known_hash(frame, ZSTR_KNOWN(ZEND_STR_ARGS)); + if (tmp) { + _build_trace_args_list(tmp, &str); + } + + return smart_str_extract(&str); +} +/* }}} */ + +/* {{{ Gets the currently executing function's arguments as a string. Used by php_verror. */ +ZEND_API zend_string *zend_trace_current_function_args_string(void) { + zend_string *dynamic_params = NULL; + /* get a backtrace to snarf function args */ + zval backtrace; + zend_fetch_debug_backtrace(&backtrace, /* skip_last */ 0, /* options */ 0, /* limit */ 1); + /* can fail esp if low memory condition */ + if (Z_TYPE(backtrace) != IS_ARRAY) { + return NULL; + } + zval *first_frame = zend_hash_index_find(Z_ARRVAL(backtrace), 0); + if (first_frame) { + dynamic_params = zend_trace_function_args_to_string(Z_ARRVAL_P(first_frame)); + } + zval_ptr_dtor(&backtrace); + return dynamic_params; +} +/* }}} */ + ZEND_API zend_string *zend_trace_to_string(const HashTable *trace, bool include_main) { zend_ulong index; zval *frame; diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h index f9b472598012..7ef9ef016393 100644 --- a/Zend/zend_exceptions.h +++ b/Zend/zend_exceptions.h @@ -65,6 +65,8 @@ ZEND_API zend_result zend_update_exception_properties(zend_execute_data *execute /* show an exception using zend_error(severity,...), severity should be E_ERROR */ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *exception, int severity); ZEND_NORETURN void zend_exception_uncaught_error(const char *prefix, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2); +ZEND_API zend_string *zend_trace_function_args_to_string(const HashTable *frame); +ZEND_API zend_string *zend_trace_current_function_args_string(void); ZEND_API zend_string *zend_trace_to_string(const HashTable *trace, bool include_main); ZEND_API ZEND_COLD zend_object *zend_create_unwind_exit(void); diff --git a/main/main.c b/main/main.c index cc3f1cae2586..fa2144783c45 100644 --- a/main/main.c +++ b/main/main.c @@ -62,6 +62,7 @@ #include "win32/php_registry.h" #include "ext/standard/flock_compat.h" #endif +#include "Zend/zend_builtin_functions.h" #include "Zend/zend_exceptions.h" #if PHP_SIGCHILD @@ -1132,7 +1133,12 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ /* if we still have memory then format the origin */ if (is_function) { - origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, params); + zend_string *dynamic_params = NULL; + dynamic_params = zend_trace_current_function_args_string(); + origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, dynamic_params ? ZSTR_VAL(dynamic_params) : params); + if (dynamic_params) { + zend_string_release(dynamic_params); + } } else { origin_len = strlen(function); origin = estrndup(function, origin_len); From 4324e640625a09c3bef327c0c20044db47b8ac1e Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Thu, 12 Dec 2024 14:26:46 -0400 Subject: [PATCH 2/8] Gate new error func arg display behind display_error_function_args This is a useful feature, but enabling it by default requires rewriting every PHPT file's output section. Since that would be a hellish diff to make and to review, I think the best option is unfortunately, another INI option. We can enable this for prod/dev recommended INIs, but make sure it's disabled for the test runner. This takes some inspiration from the discussion in GH-17056, which has similar problems to this PR. --- main/main.c | 5 ++++- main/php_globals.h | 1 + php.ini-development | 9 +++++++++ php.ini-production | 9 +++++++++ run-tests.php | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/main/main.c b/main/main.c index fa2144783c45..516d4f937f90 100644 --- a/main/main.c +++ b/main/main.c @@ -801,6 +801,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode) STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals) + STD_PHP_INI_BOOLEAN("display_error_function_args", "0", PHP_INI_ALL, OnUpdateBool, display_error_function_args, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals) STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals) @@ -1134,7 +1135,9 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ /* if we still have memory then format the origin */ if (is_function) { zend_string *dynamic_params = NULL; - dynamic_params = zend_trace_current_function_args_string(); + if (PG(display_error_function_args)) { + dynamic_params = zend_trace_current_function_args_string(); + } origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, dynamic_params ? ZSTR_VAL(dynamic_params) : params); if (dynamic_params) { zend_string_release(dynamic_params); diff --git a/main/php_globals.h b/main/php_globals.h index f6f57e0045c8..4a07bba5ab1b 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -59,6 +59,7 @@ struct _php_core_globals { uint8_t display_errors; bool display_startup_errors; + bool display_error_function_args; bool log_errors; bool ignore_repeated_errors; bool ignore_repeated_source; diff --git a/php.ini-development b/php.ini-development index ee75459ea56c..a6f060618ac6 100644 --- a/php.ini-development +++ b/php.ini-development @@ -611,6 +611,15 @@ ignore_repeated_source = Off ; Production Value: On ;fatal_error_backtraces = On +; This directive controls whether PHP will print the actual arguments of a +; function upon an error. If disabled (or there was an error fetching the +; arguments), the function providing the error may optionally provide some +; additional information after the problem function's name. +; Default Value: Off +; Development Value: On +; Production Value: On +display_error_function_args = On + ;;;;;;;;;;;;;;;;; ; Data Handling ; ;;;;;;;;;;;;;;;;; diff --git a/php.ini-production b/php.ini-production index b10e2ba9944a..2ed46f1add6c 100644 --- a/php.ini-production +++ b/php.ini-production @@ -613,6 +613,15 @@ ignore_repeated_source = Off ; Production Value: On ;fatal_error_backtraces = On +; This directive controls whether PHP will print the actual arguments of a +; function upon an error. If disabled (or there was an error fetching the +; arguments), the function providing the error may optionally provide some +; additional information after the problem function's name. +; Default Value: Off +; Development Value: On +; Production Value: On +display_error_function_args = On + ;;;;;;;;;;;;;;;;; ; Data Handling ; ;;;;;;;;;;;;;;;;; diff --git a/run-tests.php b/run-tests.php index c08d07cdd7c1..20fc7338fcb2 100755 --- a/run-tests.php +++ b/run-tests.php @@ -273,6 +273,7 @@ function main(): void 'fatal_error_backtraces=Off', 'display_errors=1', 'display_startup_errors=1', + 'display_error_function_args=0', 'log_errors=0', 'html_errors=0', 'track_errors=0', From 060d9710f9caa4279eab8f3524f2b9f9a3cc90b6 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Tue, 3 Mar 2026 17:25:36 -0400 Subject: [PATCH 3/8] Add test for display_error_function_args If this is not enabled by default for tests (like the fatal error backtrace RFC), then at least test for it. --- Zend/tests/display_error_function_args.phpt | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Zend/tests/display_error_function_args.phpt diff --git a/Zend/tests/display_error_function_args.phpt b/Zend/tests/display_error_function_args.phpt new file mode 100644 index 000000000000..785539bef8cd --- /dev/null +++ b/Zend/tests/display_error_function_args.phpt @@ -0,0 +1,30 @@ +--TEST-- +Displaying function arguments in errors +--INI-- +display_error_function_args=On +--FILE-- + "123456789012345678901" . chr(0), "cost" => 4]; +password_hash("test", PASSWORD_BCRYPT, $flags); + +ini_set("display_error_function_args", "Off"); + +unlink('/'); +password_hash("test", PASSWORD_BCRYPT, $flags); + +?> +--EXPECTF-- +Warning: unlink('/'): %s in %s on line %d + +Warning: password_hash(Object(SensitiveParameterValue), '2y', Array): The "salt" option has been ignored, since providing a custom salt is no longer supported in %s on line %d + +Warning: unlink(/): %s in %s on line %d + +Warning: password_hash(): The "salt" option has been ignored, since providing a custom salt is no longer supported in %s on line %d From 83a6868e55de3ae0a8a0dd3cba396b7f0c16b121 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Mon, 30 Mar 2026 17:28:42 -0300 Subject: [PATCH 4/8] Rename option to error_ignore_args Per feedback from Tim on the RFC. Also rationalize the default vs. recommended INI settings. This does invert the semantics for the option; the if is changed accordingly. --- Zend/tests/display_error_function_args.phpt | 4 ++-- main/main.c | 4 ++-- main/php_globals.h | 2 +- php.ini-development | 8 ++++---- php.ini-production | 8 ++++---- run-tests.php | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Zend/tests/display_error_function_args.phpt b/Zend/tests/display_error_function_args.phpt index 785539bef8cd..d7f4ee4181bb 100644 --- a/Zend/tests/display_error_function_args.phpt +++ b/Zend/tests/display_error_function_args.phpt @@ -1,7 +1,7 @@ --TEST-- Displaying function arguments in errors --INI-- -display_error_function_args=On +error_ignore_args=Off --FILE-- "123456789012345678901" . chr(0), "cost" => 4]; password_hash("test", PASSWORD_BCRYPT, $flags); -ini_set("display_error_function_args", "Off"); +ini_set("error_ignore_args", "On"); unlink('/'); password_hash("test", PASSWORD_BCRYPT, $flags); diff --git a/main/main.c b/main/main.c index 516d4f937f90..659b5c8464cb 100644 --- a/main/main.c +++ b/main/main.c @@ -801,8 +801,8 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode) STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("display_error_function_args", "0", PHP_INI_ALL, OnUpdateBool, display_error_function_args, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals) + STD_PHP_INI_BOOLEAN("error_ignore_args", "0", PHP_INI_ALL, OnUpdateBool, error_ignore_args, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals) STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals) STD_PHP_INI_ENTRY("docref_ext", "", PHP_INI_ALL, OnUpdateString, docref_ext, php_core_globals, core_globals) @@ -1135,7 +1135,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ /* if we still have memory then format the origin */ if (is_function) { zend_string *dynamic_params = NULL; - if (PG(display_error_function_args)) { + if (PG(error_ignore_args) == false) { dynamic_params = zend_trace_current_function_args_string(); } origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, dynamic_params ? ZSTR_VAL(dynamic_params) : params); diff --git a/main/php_globals.h b/main/php_globals.h index 4a07bba5ab1b..3045f5a443d5 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -59,7 +59,7 @@ struct _php_core_globals { uint8_t display_errors; bool display_startup_errors; - bool display_error_function_args; + bool error_ignore_args; bool log_errors; bool ignore_repeated_errors; bool ignore_repeated_source; diff --git a/php.ini-development b/php.ini-development index a6f060618ac6..dcd4b55616df 100644 --- a/php.ini-development +++ b/php.ini-development @@ -612,13 +612,13 @@ ignore_repeated_source = Off ;fatal_error_backtraces = On ; This directive controls whether PHP will print the actual arguments of a -; function upon an error. If disabled (or there was an error fetching the +; function upon an error. If this is on (or there was an error fetching the ; arguments), the function providing the error may optionally provide some ; additional information after the problem function's name. ; Default Value: Off -; Development Value: On -; Production Value: On -display_error_function_args = On +; Development Value: Off +; Production Value: Off +;error_ignore_args = Off ;;;;;;;;;;;;;;;;; ; Data Handling ; diff --git a/php.ini-production b/php.ini-production index 2ed46f1add6c..51703733fcc3 100644 --- a/php.ini-production +++ b/php.ini-production @@ -614,13 +614,13 @@ ignore_repeated_source = Off ;fatal_error_backtraces = On ; This directive controls whether PHP will print the actual arguments of a -; function upon an error. If disabled (or there was an error fetching the +; function upon an error. If this is on (or there was an error fetching the ; arguments), the function providing the error may optionally provide some ; additional information after the problem function's name. ; Default Value: Off -; Development Value: On -; Production Value: On -display_error_function_args = On +; Development Value: Off +; Production Value: Off +;error_ignore_args = Off ;;;;;;;;;;;;;;;;; ; Data Handling ; diff --git a/run-tests.php b/run-tests.php index 20fc7338fcb2..2b8d6286117e 100755 --- a/run-tests.php +++ b/run-tests.php @@ -273,7 +273,7 @@ function main(): void 'fatal_error_backtraces=Off', 'display_errors=1', 'display_startup_errors=1', - 'display_error_function_args=0', + 'error_ignore_args=1', 'log_errors=0', 'html_errors=0', 'track_errors=0', From 3f0e8cffa046c0fd98ef93fa418308e539fb346d Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Mon, 30 Mar 2026 19:37:27 -0300 Subject: [PATCH 5/8] Fix this test since it calls PHP itself Almost certainly a better way to do this... --- sapi/cli/tests/php_cli_server.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc index 3022022f894e..30812b180e5f 100644 --- a/sapi/cli/tests/php_cli_server.inc +++ b/sapi/cli/tests/php_cli_server.inc @@ -24,7 +24,8 @@ function php_cli_server_start( file_put_contents($doc_root . '/' . ($router ?: 'index.php'), ''); } - $cmd = [$php_executable, '-t', $doc_root, '-n', ...$cmd_args, '-S', 'localhost:0']; + // XXX: This should ideally use the same INI overrides as run-tests + $cmd = [$php_executable, '-d', 'error_ignore_args=1', '-t', $doc_root, '-n', ...$cmd_args, '-S', 'localhost:0']; if (!is_null($router)) { $cmd[] = $router; } From 6e887924f55e2f40933d9b16ff9cd5eaf54be3ed Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Mon, 30 Mar 2026 21:00:24 -0300 Subject: [PATCH 6/8] Quick hack to placate Windows OpenSSL tests w/ new INI opt --- ext/openssl/tests/ServerClientTestCase.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/openssl/tests/ServerClientTestCase.inc b/ext/openssl/tests/ServerClientTestCase.inc index f0336fdd3921..a61368f7c751 100644 --- a/ext/openssl/tests/ServerClientTestCase.inc +++ b/ext/openssl/tests/ServerClientTestCase.inc @@ -100,7 +100,8 @@ class ServerClientTestCase $ini = php_ini_loaded_file(); $cmd = sprintf( '%s %s "%s" %s', - PHP_BINARY, $ini ? "-n -c $ini" : "", + // XXX: TEST_PHP_EXTRA_ARGS for run-test values won't work here? + PHP_BINARY, $ini ? "-n -c $ini -d error_ignore_args=1" : "", __FILE__, WORKER_ARGV_VALUE ); From 8e0e56bd639485a6561c8395022e5dd1144c4861 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Thu, 2 Apr 2026 15:40:13 -0300 Subject: [PATCH 7/8] Rename to error_include_args Avoid a negative which is harder to reason about; matches RFC change --- Zend/tests/display_error_function_args.phpt | 4 ++-- ext/openssl/tests/ServerClientTestCase.inc | 2 +- main/main.c | 4 ++-- main/php_globals.h | 2 +- php.ini-development | 4 ++-- php.ini-production | 4 ++-- run-tests.php | 2 +- sapi/cli/tests/php_cli_server.inc | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Zend/tests/display_error_function_args.phpt b/Zend/tests/display_error_function_args.phpt index d7f4ee4181bb..c28a4a2808b4 100644 --- a/Zend/tests/display_error_function_args.phpt +++ b/Zend/tests/display_error_function_args.phpt @@ -1,7 +1,7 @@ --TEST-- Displaying function arguments in errors --INI-- -error_ignore_args=Off +error_include_args=On --FILE-- "123456789012345678901" . chr(0), "cost" => 4]; password_hash("test", PASSWORD_BCRYPT, $flags); -ini_set("error_ignore_args", "On"); +ini_set("error_include_args", "Off"); unlink('/'); password_hash("test", PASSWORD_BCRYPT, $flags); diff --git a/ext/openssl/tests/ServerClientTestCase.inc b/ext/openssl/tests/ServerClientTestCase.inc index a61368f7c751..c5db41d48417 100644 --- a/ext/openssl/tests/ServerClientTestCase.inc +++ b/ext/openssl/tests/ServerClientTestCase.inc @@ -101,7 +101,7 @@ class ServerClientTestCase $cmd = sprintf( '%s %s "%s" %s', // XXX: TEST_PHP_EXTRA_ARGS for run-test values won't work here? - PHP_BINARY, $ini ? "-n -c $ini -d error_ignore_args=1" : "", + PHP_BINARY, $ini ? "-n -c $ini -d error_include_args=0" : "", __FILE__, WORKER_ARGV_VALUE ); diff --git a/main/main.c b/main/main.c index 659b5c8464cb..9c8a30ec9c66 100644 --- a/main/main.c +++ b/main/main.c @@ -802,7 +802,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode) STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("error_ignore_args", "0", PHP_INI_ALL, OnUpdateBool, error_ignore_args, php_core_globals, core_globals) + STD_PHP_INI_BOOLEAN("error_include_args", "1", PHP_INI_ALL, OnUpdateBool, error_include_args, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals) STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals) STD_PHP_INI_ENTRY("docref_ext", "", PHP_INI_ALL, OnUpdateString, docref_ext, php_core_globals, core_globals) @@ -1135,7 +1135,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ /* if we still have memory then format the origin */ if (is_function) { zend_string *dynamic_params = NULL; - if (PG(error_ignore_args) == false) { + if (PG(error_include_args)) { dynamic_params = zend_trace_current_function_args_string(); } origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, dynamic_params ? ZSTR_VAL(dynamic_params) : params); diff --git a/main/php_globals.h b/main/php_globals.h index 3045f5a443d5..8a032e9edb13 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -59,7 +59,7 @@ struct _php_core_globals { uint8_t display_errors; bool display_startup_errors; - bool error_ignore_args; + bool error_include_args; bool log_errors; bool ignore_repeated_errors; bool ignore_repeated_source; diff --git a/php.ini-development b/php.ini-development index dcd4b55616df..be6f44e2fd94 100644 --- a/php.ini-development +++ b/php.ini-development @@ -612,13 +612,13 @@ ignore_repeated_source = Off ;fatal_error_backtraces = On ; This directive controls whether PHP will print the actual arguments of a -; function upon an error. If this is on (or there was an error fetching the +; function upon an error. If this is off (or there was an error fetching the ; arguments), the function providing the error may optionally provide some ; additional information after the problem function's name. ; Default Value: Off ; Development Value: Off ; Production Value: Off -;error_ignore_args = Off +;error_include_args = Off ;;;;;;;;;;;;;;;;; ; Data Handling ; diff --git a/php.ini-production b/php.ini-production index 51703733fcc3..b67814c4436a 100644 --- a/php.ini-production +++ b/php.ini-production @@ -614,13 +614,13 @@ ignore_repeated_source = Off ;fatal_error_backtraces = On ; This directive controls whether PHP will print the actual arguments of a -; function upon an error. If this is on (or there was an error fetching the +; function upon an error. If this is off (or there was an error fetching the ; arguments), the function providing the error may optionally provide some ; additional information after the problem function's name. ; Default Value: Off ; Development Value: Off ; Production Value: Off -;error_ignore_args = Off +;error_include_args = Off ;;;;;;;;;;;;;;;;; ; Data Handling ; diff --git a/run-tests.php b/run-tests.php index 2b8d6286117e..f5c7be8b4f45 100755 --- a/run-tests.php +++ b/run-tests.php @@ -273,7 +273,7 @@ function main(): void 'fatal_error_backtraces=Off', 'display_errors=1', 'display_startup_errors=1', - 'error_ignore_args=1', + 'error_include_args=0', 'log_errors=0', 'html_errors=0', 'track_errors=0', diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc index 30812b180e5f..3ad6ced5cb44 100644 --- a/sapi/cli/tests/php_cli_server.inc +++ b/sapi/cli/tests/php_cli_server.inc @@ -25,7 +25,7 @@ function php_cli_server_start( } // XXX: This should ideally use the same INI overrides as run-tests - $cmd = [$php_executable, '-d', 'error_ignore_args=1', '-t', $doc_root, '-n', ...$cmd_args, '-S', 'localhost:0']; + $cmd = [$php_executable, '-d', 'error_include_args=0', '-t', $doc_root, '-n', ...$cmd_args, '-S', 'localhost:0']; if (!is_null($router)) { $cmd[] = $router; } From 9e866bef9490bdbacc458a6348fe6fab18a46df6 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Tue, 12 May 2026 18:28:29 -0300 Subject: [PATCH 8/8] Default error_include_args to Off RFC is going towards adding this, but disabling it by default. --- main/main.c | 2 +- php.ini-development | 3 --- php.ini-production | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/main/main.c b/main/main.c index 9c8a30ec9c66..6bda55ac8746 100644 --- a/main/main.c +++ b/main/main.c @@ -802,7 +802,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode) STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("error_include_args", "1", PHP_INI_ALL, OnUpdateBool, error_include_args, php_core_globals, core_globals) + STD_PHP_INI_BOOLEAN("error_include_args", "0", PHP_INI_ALL, OnUpdateBool, error_include_args, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals) STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals) STD_PHP_INI_ENTRY("docref_ext", "", PHP_INI_ALL, OnUpdateString, docref_ext, php_core_globals, core_globals) diff --git a/php.ini-development b/php.ini-development index be6f44e2fd94..7ac9eefedfad 100644 --- a/php.ini-development +++ b/php.ini-development @@ -615,9 +615,6 @@ ignore_repeated_source = Off ; function upon an error. If this is off (or there was an error fetching the ; arguments), the function providing the error may optionally provide some ; additional information after the problem function's name. -; Default Value: Off -; Development Value: Off -; Production Value: Off ;error_include_args = Off ;;;;;;;;;;;;;;;;; diff --git a/php.ini-production b/php.ini-production index b67814c4436a..c82cde46082b 100644 --- a/php.ini-production +++ b/php.ini-production @@ -617,9 +617,6 @@ ignore_repeated_source = Off ; function upon an error. If this is off (or there was an error fetching the ; arguments), the function providing the error may optionally provide some ; additional information after the problem function's name. -; Default Value: Off -; Development Value: Off -; Production Value: Off ;error_include_args = Off ;;;;;;;;;;;;;;;;;