Panel error when using two connections
jandanielcz opened this issue · comments
jandanielcz commented
Version: v4.2.6
Bug Description
I use two connections to PDO MySQL, and register them both to Panel. It shows errors instead of proper informations.
Error message:
Error: Dibi\Bridges\Tracy\Panel
TypeError: Dibi\Bridges\Tracy\Panel::getConnectionName(): Argument #1 ($connection) must be of type Dibi\Connection, null given, called in C:\code\dibi-demo\vendor\dibi\dibi\src\Dibi\Bridges\Tracy\Panel.php on line 164 and defined in C:\code\dibi-demo\vendor\dibi\dibi\src\Dibi\Bridges\Tracy\Panel.php:174
Stack trace:
#0 C:\code\dibi-demo\vendor\dibi\dibi\src\Dibi\Bridges\Tracy\Panel.php(164): Dibi\Bridges\Tracy\Panel->getConnectionName(NULL)
#1 C:\code\dibi-demo\vendor\tracy\tracy\src\Tracy\Bar\Bar.php(141): Dibi\Bridges\Tracy\Panel->getPanel()
#2 C:\code\dibi-demo\vendor\tracy\tracy\src\Tracy\Bar\Bar.php(113): Tracy\Bar->renderPanels('')
#3 C:\code\dibi-demo\vendor\tracy\tracy\src\Tracy\Bar\Bar.php(87): Tracy\Bar->renderPartial('main')
#4 C:\code\dibi-demo\vendor\tracy\tracy\src\Tracy\Debugger\DevelopmentStrategy.php(138): Tracy\Bar->render(Object(Tracy\DeferredContent))
#5 C:\code\dibi-demo\vendor\tracy\tracy\src\Tracy\Debugger\Debugger.php(295): Tracy\DevelopmentStrategy->renderBar()
#6 [internal function]: Tracy\Debugger::shutdownHandler()
#7 {main}
Steps To Reproduce
<?php
require "vendor/autoload.php";
\Tracy\Debugger::enable();
$c1 = new \Dibi\Connection([
'driver' => 'pdo',
'dsn' => 'mysql:host=127.0.0.1;port=3306;dbname=bylsem;charset=utf8mb4',
'username' => 'root',
'password' => 'toor',
], 'Write');
$c2 = new \Dibi\Connection([
'driver' => 'pdo',
'dsn' => 'mysql:host=127.0.0.1;port=3306;dbname=bylsem;charset=utf8mb4',
'username' => 'read',
'password' => 'toor',
], 'Read');
$panel = new \Dibi\Bridges\Tracy\Panel();
$panel->register($c1);
$panel->register($c2);
$c1->fetchAll(['select * from user']);
$c2->fetchAll(['select * from activity']);
exit;
Expected Behavior
I do expect two windows separated by connection, with proper informations.
Thanks
Miloslav Hůla commented
I think that panel is only for one connection. Try
(new \Dibi\Bridges\Tracy\Panel)->register($c1);
(new \Dibi\Bridges\Tracy\Panel)->register($c2);
jandanielcz commented
I think that panel is only for one connection. Try
(new \Dibi\Bridges\Tracy\Panel)->register($c1); (new \Dibi\Bridges\Tracy\Panel)->register($c2);
This works, thanks! Should I now close this issue?
eydun commented
Yes, I think you should close this issue.