From 69addc15eafeda33be24c10ce15b737da0f450f8 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 28 May 2020 16:58:28 +0200 Subject: [PATCH] LSlog :: get_debug_backtrace_context(): fix/improve method --- src/includes/class/class.LSlog.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/includes/class/class.LSlog.php b/src/includes/class/class.LSlog.php index 7d77a6fd..4e0a8b4e 100644 --- a/src/includes/class/class.LSlog.php +++ b/src/includes/class/class.LSlog.php @@ -286,12 +286,14 @@ class LSlog { **/ public static function get_debug_backtrace_context() { $traces = debug_backtrace(); - if (!is_array($traces) || count($traces) <= 2) - return ""; + if (!is_array($traces) || count($traces) < 2) + return "unknown context"; $msg = array(); - for ($i=2; $i < count($traces); $i++) { - $trace = array("#$i"); + $j=0; + for ($i=count($traces)-1; $i >= 1; $i--) { + $j += 1; + $trace = array("#$j"); if (isset($traces[$i]['file'])) $trace[] = $traces[$i]['file'].(isset($traces[$i]['line'])?":".$traces[$i]['line']:""); if (isset($traces[$i]['class']) && isset($traces[$i]['function']))