Skip to content

Commit a6f5a3b

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 f4a43ea commit a6f5a3b

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

main/main.c

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

804804
STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode)
805805
STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
806+
STD_PHP_INI_BOOLEAN("display_error_function_args", "0", PHP_INI_ALL, OnUpdateBool, display_error_function_args, php_core_globals, core_globals)
806807
STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals)
807808
STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals)
808809
STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals)
@@ -1136,7 +1137,13 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
11361137
/* if we still have memory then format the origin */
11371138
if (is_function) {
11381139
zend_string *dynamic_params = NULL;
1139-
dynamic_params = zend_trace_current_function_args_string();
1140+
/*
1141+
* By default, this is disabled because it requires rewriting
1142+
* almost all PHPT files.
1143+
*/
1144+
if (PG(display_error_function_args)) {
1145+
dynamic_params = zend_trace_current_function_args_string();
1146+
}
11401147
origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, dynamic_params ? ZSTR_VAL(dynamic_params) : params);
11411148
if (dynamic_params) {
11421149
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)