diff --git a/common/framework/DB.php b/common/framework/DB.php
index 3013fd803..1388d2696 100644
--- a/common/framework/DB.php
+++ b/common/framework/DB.php
@@ -1269,7 +1269,7 @@ class DB
if (isset($backtrace[$no]))
{
$result['called_method'] = ($backtrace[$no]['class'] ?? '') . ($backtrace[$no]['type'] ?? '') . ($backtrace[$no]['function'] ?? '');
- $result['backtrace'] = $this->_debug_full_stack ? array_slice($backtrace, $no) : [];
+ $result['backtrace'] = $this->_debug_full_stack ? array_slice($backtrace, $no - 1) : [];
}
else
{
diff --git a/common/js/debug.js b/common/js/debug.js
index 9214ec41f..86ab6f548 100644
--- a/common/js/debug.js
+++ b/common/js/debug.js
@@ -148,7 +148,7 @@ $(function() {
if (data.queries[i].backtrace && data.queries[i].backtrace.length) {
backtrace = $('
').appendTo(description.find('li:first-child'));
for (j in data.queries[i].backtrace) {
- if (data.queries[i].backtrace[j].file) {
+ if (j > 0 && data.queries[i].backtrace[j].file) {
backtrace.append($('').text(data.queries[i].backtrace[j].file + ":" + data.queries[i].backtrace[j].line));
}
}
diff --git a/common/tpl/debug_comment.html b/common/tpl/debug_comment.html
index 32faf73cb..b07a39ff3 100644
--- a/common/tpl/debug_comment.html
+++ b/common/tpl/debug_comment.html
@@ -126,7 +126,7 @@ Database Queries
echo sprintf(' - Call Stack: %s', $query_caller) . ($query->count > 1 ? (' (×' . $query->count . ')') : '') . "\n";
foreach ($query->backtrace ?? [] as $key => $backtrace)
{
- if (isset($backtrace['file']) && isset($backtrace['line']))
+ if ($key > 0 && isset($backtrace['file']) && isset($backtrace['line']))
{
echo sprintf(' %s line %d', $backtrace['file'], $backtrace['line']) . "\n";
}