Skip to content

Commit

Permalink
ConnectionPanel: fixed bad source file [Closes nette/tracy#346]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 26, 2019
1 parent 044d878 commit 09c71d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/Bridges/DatabaseTracy/ConnectionPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Nette\Bridges\DatabaseTracy;

use Nette;
use Nette\Database\Connection;
use Nette\Database\Helpers;
use Tracy;

Expand Down Expand Up @@ -43,13 +44,13 @@ class ConnectionPanel implements Tracy\IBarPanel
private $queries = [];


public function __construct(Nette\Database\Connection $connection)
public function __construct(Connection $connection)
{
$connection->onQuery[] = [$this, 'logQuery'];
}


public function logQuery(Nette\Database\Connection $connection, $result): void
public function logQuery(Connection $connection, $result): void
{
if ($this->disabled) {
return;
Expand All @@ -59,13 +60,11 @@ public function logQuery(Nette\Database\Connection $connection, $result): void
$source = null;
$trace = $result instanceof \PDOException ? $result->getTrace() : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
foreach ($trace as $row) {
if (isset($row['file']) && is_file($row['file']) && !Tracy\Debugger::getBluescreen()->isCollapsed($row['file'])) {
if (
(strpos($row['function'] ?? '', 'call_user_func') === 0)
|| (is_subclass_of($row['class'] ?? '', '\\Nette\\Database\\Connection'))
) {
continue;
}
if (
(isset($row['file']) && is_file($row['file']) && !Tracy\Debugger::getBluescreen()->isCollapsed($row['file']))
&& ($row['class'] ?? '') !== self::class
&& !is_a($row['class'] ?? '', Connection::class, true)
) {
$source = [$row['file'], (int) $row['line']];
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use Tracy;

<div class="tracy-inner">
<div class="tracy-inner-container">
<table>
<table class="tracy-sortable">
<tr><th>Time&nbsp;ms</th><th>SQL Query</th><th>Rows</th></tr>
<?php
foreach ($queries as $query):
Expand Down

0 comments on commit 09c71d4

Please sign in to comment.