From 7428f084fd31cce336ac77490b6e41f6183adfcb Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Mon, 23 Nov 2026 15:26:36 -0800 Subject: [PATCH 1/2] `zend_fetch_debug_backtrace`: use `bool` for `skip_last` --- UPGRADING.INTERNALS | 2 ++ Zend/zend.c | 2 +- Zend/zend_builtin_functions.c | 6 +++--- Zend/zend_builtin_functions.h | 2 +- Zend/zend_exceptions.c | 4 ++-- ext/reflection/php_reflection.c | 4 ++-- sapi/phpdbg/phpdbg_frame.c | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index a2f9bc7f01c9..07d15b109999 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -85,6 +85,8 @@ PHP 8.7 INTERNALS UPGRADE NOTES from zend_is_callable(const zval *callable, uint32_t check_flags, zend_string **callable_name). This new signature covers the most common parameters used with zend_is_callable_ex(). + . The `skip_last` parameter of `zend_fetch_debug_backtrace()` is now declared + as a `bool` rather than an `int`. - Added: . The zend_object_copy() function was added to increases the refcount of a diff --git a/Zend/zend.c b/Zend/zend.c index 560a365318de..3b68f63674bb 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1543,7 +1543,7 @@ ZEND_API ZEND_COLD void zend_error_zstr_at( // EG(last_fatal_error_backtrace) is useless when the executor is // inactive, and setting it at this point would leak. if (EG(active)) { - zend_fetch_debug_backtrace(&EG(last_fatal_error_backtrace), 0, EG(exception_ignore_args) ? DEBUG_BACKTRACE_IGNORE_ARGS : 0, 0); + zend_fetch_debug_backtrace(&EG(last_fatal_error_backtrace), false, EG(exception_ignore_args) ? DEBUG_BACKTRACE_IGNORE_ARGS : 0, 0); } } diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 2f37007f4be4..f570c8095280 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1904,7 +1904,7 @@ ZEND_FUNCTION(debug_print_backtrace) RETURN_THROWS(); } - zend_fetch_debug_backtrace(&backtrace, 1, options, limit); + zend_fetch_debug_backtrace(&backtrace, true, options, limit); ZEND_ASSERT(Z_TYPE(backtrace) == IS_ARRAY); zend_string *str = zend_trace_to_string(Z_ARRVAL(backtrace), /* include_main */ false); @@ -1915,7 +1915,7 @@ ZEND_FUNCTION(debug_print_backtrace) /* }}} */ -ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit) /* {{{ */ +ZEND_API void zend_fetch_debug_backtrace(zval *return_value, bool skip_last, int options, int limit) /* {{{ */ { zend_execute_data *call, *last_call = NULL; zend_object *object; @@ -2257,7 +2257,7 @@ ZEND_FUNCTION(debug_backtrace) RETURN_THROWS(); } - zend_fetch_debug_backtrace(return_value, 1, options, limit); + zend_fetch_debug_backtrace(return_value, true, options, limit); } /* }}} */ diff --git a/Zend/zend_builtin_functions.h b/Zend/zend_builtin_functions.h index 018d0cdb1c1d..8dfa330485cd 100644 --- a/Zend/zend_builtin_functions.h +++ b/Zend/zend_builtin_functions.h @@ -26,7 +26,7 @@ typedef struct _zval_struct zval; zend_result zend_startup_builtin_functions(void); BEGIN_EXTERN_C() -ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit); +ZEND_API void zend_fetch_debug_backtrace(zval *return_value, bool skip_last, int options, int limit); END_EXTERN_C() #endif /* ZEND_BUILTIN_FUNCTIONS_H */ diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index b5ccb74d7df7..d39e58542ba9 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -268,7 +268,7 @@ static zend_object *zend_default_exception_new(zend_class_entry *class_type) /* if (EG(current_execute_data)) { zend_fetch_debug_backtrace(&trace, - 0, + false, EG(exception_ignore_args) ? DEBUG_BACKTRACE_IGNORE_ARGS : 0, 0); } else { ZVAL_EMPTY_ARRAY(&trace); @@ -656,7 +656,7 @@ ZEND_API zend_string *zend_trace_current_function_args_string(void) { /* get a backtrace to snarf function args */ zval backtrace; - zend_fetch_debug_backtrace(&backtrace, /* skip_last */ 0, /* options */ 0, /* limit */ 1); + zend_fetch_debug_backtrace(&backtrace, /* skip_last */ false, /* options */ 0, /* limit */ 1); /* can fail esp if low memory condition */ if (Z_TYPE(backtrace) == IS_ARRAY) { zval *first_frame = zend_hash_index_find(Z_ARRVAL(backtrace), 0); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index de814d9cf66c..6f6087ad9b72 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2303,7 +2303,7 @@ ZEND_METHOD(ReflectionGenerator, getTrace) } EG(current_execute_data) = root_generator->execute_data; - zend_fetch_debug_backtrace(return_value, 0, options, 0); + zend_fetch_debug_backtrace(return_value, false, options, 0); EG(current_execute_data) = ex_backup; root_generator->execute_data->prev_execute_data = root_prev; @@ -7884,7 +7884,7 @@ ZEND_METHOD(ReflectionFiber, getTrace) EG(current_execute_data) = fiber->execute_data; } - zend_fetch_debug_backtrace(return_value, 0, options, 0); + zend_fetch_debug_backtrace(return_value, false, options, 0); EG(current_execute_data) = execute_data; // Restore original execute data. fiber->stack_bottom->prev_execute_data = prev_execute_data; // Restore prev execute data on fiber stack. diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index fdab924638ea..3e1dc6e38d63 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -259,7 +259,7 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */ } phpdbg_try_access { - zend_fetch_debug_backtrace(&zbacktrace, 0, 0, limit); + zend_fetch_debug_backtrace(&zbacktrace, false, 0, limit); } phpdbg_catch_access { phpdbg_error("Couldn't fetch backtrace, invalid data source"); return; From e44f62c34379db4f99b676aa91c137b5eab97814 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Mon, 23 Nov 2026 16:26:00 -0800 Subject: [PATCH 2/2] Revert UPGRADING.INTERNALS --- UPGRADING.INTERNALS | 2 -- 1 file changed, 2 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 07d15b109999..a2f9bc7f01c9 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -85,8 +85,6 @@ PHP 8.7 INTERNALS UPGRADE NOTES from zend_is_callable(const zval *callable, uint32_t check_flags, zend_string **callable_name). This new signature covers the most common parameters used with zend_is_callable_ex(). - . The `skip_last` parameter of `zend_fetch_debug_backtrace()` is now declared - as a `bool` rather than an `int`. - Added: . The zend_object_copy() function was added to increases the refcount of a