From 0838a2b3dfc4e3d71417a73b3619cc5e16f82824 Mon Sep 17 00:00:00 2001 From: zymeli <710055@qq.com> Date: Mon, 4 Dec 2023 22:53:47 +0800 Subject: [PATCH] Fix #528: Fix `yii\debug\Panel::getTraceLine()` to handle backtrace for internal PHP functions --- CHANGELOG.md | 2 +- src/Panel.php | 8 ++++++++ src/views/default/index.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be3b8c253..fce95457a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 debug extension Change Log 2.1.26 under development ------------------------ -- no changes in this release. +- Bug #528: Fix `yii\debug\Panel::getTraceLine()` to handle backtrace for internal PHP functions (zymeli) 2.1.25 September 26, 2023 diff --git a/src/Panel.php b/src/Panel.php index a38abcb4e..d2857781c 100644 --- a/src/Panel.php +++ b/src/Panel.php @@ -131,6 +131,14 @@ public function getUrl($additionalParams = null) */ public function getTraceLine($options) { + /** + * If an internal PHP function, such as `call_user_func`, in the backtrace, the 'file' and 'line' not be available. + * @see https://www.php.net/manual/en/function.debug-backtrace.php#59713 + */ + if (!isset($options['file'])) { + return VarDumper::dumpAsString($options); + } + if (!isset($options['text'])) { $options['text'] = "{$options['file']}:{$options['line']}"; } diff --git a/src/views/default/index.php b/src/views/default/index.php index e092b0dfb..7f5a70a8f 100644 --- a/src/views/default/index.php +++ b/src/views/default/index.php @@ -17,7 +17,7 @@