Skip to content

Commit 1f3d525

Browse files
committed
Remove first two arrays in trace when called in browser
1 parent 1a52fbf commit 1f3d525

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

system/Debug/Toolbar/Collectors/Database.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,19 @@ public static function collect(Query $query)
8585
if (count(static::$queries) < $max) {
8686
$queryString = $query->getQuery();
8787

88+
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
89+
90+
if (! is_cli()) {
91+
// when called in the browser, the first two trace arrays
92+
// are from the DB event trigger, which are unneeded
93+
$backtrace = array_slice($backtrace, 2);
94+
}
95+
8896
static::$queries[] = [
8997
'query' => $query,
9098
'string' => $queryString,
9199
'duplicate' => in_array($queryString, array_column(static::$queries, 'string', null), true),
92-
'trace' => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),
100+
'trace' => $backtrace,
93101
];
94102
}
95103
}

0 commit comments

Comments
 (0)