Skip to content

Commit 12e3343

Browse files
committed
Fix QueryCollector
1 parent 307bbc4 commit 12e3343

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/DataCollector/QueryCollector.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class QueryCollector extends PDOCollector
1616
protected $timeCollector;
1717
protected $queries = [];
1818
protected $queryCount = 0;
19+
protected $transactionEventsCount = 0;
1920
protected $softLimit = null;
2021
protected $hardLimit = null;
2122
protected $lastMemoryUsage;
@@ -439,6 +440,7 @@ protected function getTwigInfo($trace)
439440
*/
440441
public function collectTransactionEvent($event, $connection)
441442
{
443+
$this->transactionEventsCount++;
442444
$source = [];
443445

444446
if ($this->findSource) {
@@ -484,6 +486,11 @@ public function collect()
484486
$statements = [];
485487
foreach ($queries as $query) {
486488
$source = reset($query['source']);
489+
$normalizedPath = is_object($source) ? $this->normalizeFilePath($source->file ?: '') : '';
490+
if ($query['type'] != 'transaction' && Str::startsWith($normalizedPath, $this->excludePaths)) {
491+
continue;
492+
}
493+
487494
$totalTime += $query['time'];
488495
$totalMemory += $query['memory'];
489496

@@ -497,11 +504,6 @@ public function collect()
497504
default => false,
498505
};
499506

500-
$source = $this->getDataFormatter()->formatSource($source);
501-
if (Str::startsWith($source, $this->excludePaths)) {
502-
continue;
503-
}
504-
505507
$statements[] = [
506508
'sql' => $this->getSqlQueryToDisplay($query),
507509
'type' => $query['type'],
@@ -517,7 +519,7 @@ public function collect()
517519
'memory_str' => $query['memory'] ? $this->getDataFormatter()->formatBytes($query['memory']) : null,
518520
'filename' => $this->getDataFormatter()->formatSource($source, true),
519521
'source' => $source,
520-
'xdebug_link' => is_object($source) ? $this->getXdebugLink($source->file ?: '', $source->line) : null,
522+
'xdebug_link' => is_object($source) ? $this->getXdebugLink($normalizedPath, $source->line) : null,
521523
'connection' => $connectionName,
522524
'explain' => $this->explainQuery && $canExplainQuery ? [
523525
'url' => route('debugbar.queries.explain'),
@@ -580,7 +582,7 @@ public function collect()
580582
$data = [
581583
'nb_statements' => $this->queryCount,
582584
'nb_visible_statements' => count($statements),
583-
'nb_excluded_statements' => $this->queryCount - count($statements),
585+
'nb_excluded_statements' => $this->queryCount + $this->transactionEventsCount - count($statements),
584586
'nb_failed_statements' => 0,
585587
'accumulated_duration' => $totalTime,
586588
'accumulated_duration_str' => $this->formatDuration($totalTime),

0 commit comments

Comments
 (0)