Skip to content

Commit

Permalink
Gate new error func arg display behind display_error_function_args
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NattyNarwhal committed Dec 12, 2024
1 parent 985f48f commit 44b8dcd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,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)
Expand Down Expand Up @@ -1068,7 +1069,13 @@ 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();
/*
* By default, this is disabled because it requires rewriting
* almost all PHPT files.
*/
if (PG(display_error_function_args)) {
dynamic_params = zend_trace_current_function_args_string();
}
origin_len = (int)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);
Expand Down
1 change: 1 addition & 0 deletions main/php_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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;
Expand Down

0 comments on commit 44b8dcd

Please sign in to comment.