Skip to content

Commit 44b8dcd

Browse files
committed
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.
1 parent 985f48f commit 44b8dcd

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

main/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ PHP_INI_BEGIN()
738738

739739
STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode)
740740
STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
741+
STD_PHP_INI_BOOLEAN("display_error_function_args", "0", PHP_INI_ALL, OnUpdateBool, display_error_function_args, php_core_globals, core_globals)
741742
STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals)
742743
STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals)
743744
STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals)
@@ -1068,7 +1069,13 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
10681069
/* if we still have memory then format the origin */
10691070
if (is_function) {
10701071
zend_string *dynamic_params = NULL;
1071-
dynamic_params = zend_trace_current_function_args_string();
1072+
/*
1073+
* By default, this is disabled because it requires rewriting
1074+
* almost all PHPT files.
1075+
*/
1076+
if (PG(display_error_function_args)) {
1077+
dynamic_params = zend_trace_current_function_args_string();
1078+
}
10721079
origin_len = (int)spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, dynamic_params ? ZSTR_VAL(dynamic_params) : params);
10731080
if (dynamic_params) {
10741081
zend_string_release(dynamic_params);

main/php_globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct _php_core_globals {
6161

6262
uint8_t display_errors;
6363
bool display_startup_errors;
64+
bool display_error_function_args;
6465
bool log_errors;
6566
bool ignore_repeated_errors;
6667
bool ignore_repeated_source;

0 commit comments

Comments
 (0)