Skip to content

Commit 824e7f2

Browse files
committed
simple ignore arguments in backtrace implementation
1 parent d924b42 commit 824e7f2

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Exceptions ignoring arguments
3+
--FILE--
4+
<?php
5+
$function = function(string $user, string $pass) {
6+
throw new Exception();
7+
};
8+
9+
ini_set("zend.backtrace_ignore_args", 1);
10+
11+
$function("secrets", "arewrong");
12+
?>
13+
--EXPECTF--
14+
Fatal error: Uncaught Exception in %sdebug_backtrace_ignore_args.php:3
15+
Stack trace:
16+
#0 %sdebug_backtrace_ignore_args.php(8): {closure}()
17+
#1 {main}
18+
thrown in %sdebug_backtrace_ignore_args.php on line 3

Zend/zend.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ static ZEND_INI_MH(OnUpdateAssertions) /* {{{ */
164164
}
165165
/* }}} */
166166

167+
168+
167169
ZEND_INI_BEGIN()
168170
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
169171
STD_ZEND_INI_ENTRY("zend.assertions", "1", ZEND_INI_ALL, OnUpdateAssertions, assertions, zend_executor_globals, executor_globals)
@@ -174,6 +176,7 @@ ZEND_INI_BEGIN()
174176
#ifdef ZEND_SIGNALS
175177
STD_ZEND_INI_BOOLEAN("zend.signal_check", "0", ZEND_INI_SYSTEM, OnUpdateBool, check, zend_signal_globals_t, zend_signal_globals)
176178
#endif
179+
STD_ZEND_INI_BOOLEAN("zend.backtrace_ignore_args", "1", ZEND_INI_ALL, OnUpdateBool, backtrace_ignore_args, zend_executor_globals, executor_globals)
177180
ZEND_INI_END()
178181

179182
ZEND_API size_t zend_vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */

Zend/zend_builtin_functions.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,6 +2436,10 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
24362436
}
24372437
}
24382438

2439+
if (EG(backtrace_ignore_args)) {
2440+
options |= DEBUG_BACKTRACE_IGNORE_ARGS;
2441+
}
2442+
24392443
while (ptr && (limit == 0 || frameno < limit)) {
24402444
frameno++;
24412445
array_init(&stack_frame);

Zend/zend_globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ struct _zend_executor_globals {
234234

235235
HashTable weakrefs;
236236

237+
zend_bool backtrace_ignore_args;
238+
237239
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
238240
};
239241

0 commit comments

Comments
 (0)