From efe7df6916a4e8b34c6125defe03dc78c61b620b Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Sun, 3 Aug 2025 16:29:12 +0200 Subject: [PATCH] Allow SqlPanel skip drivers with no setLogger method --- src/Panel/SqlLogPanel.php | 5 +++ tests/TestCase/Panel/SqlLogPanelTest.php | 17 +++++++++ tests/test_app/Stub/SimpleConnectionStub.php | 37 ++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 tests/test_app/Stub/SimpleConnectionStub.php diff --git a/src/Panel/SqlLogPanel.php b/src/Panel/SqlLogPanel.php index 497d2f256..231a25005 100644 --- a/src/Panel/SqlLogPanel.php +++ b/src/Panel/SqlLogPanel.php @@ -68,6 +68,11 @@ public static function addConnection(string $name): void return; } $driver = $connection->getDriver(); + + if (!method_exists($driver, 'setLogger')) { + return; + } + $logger = null; if ($driver instanceof Driver) { $logger = $driver->getLogger(); diff --git a/tests/TestCase/Panel/SqlLogPanelTest.php b/tests/TestCase/Panel/SqlLogPanelTest.php index d43dd48ab..a9b0d6ab4 100644 --- a/tests/TestCase/Panel/SqlLogPanelTest.php +++ b/tests/TestCase/Panel/SqlLogPanelTest.php @@ -124,4 +124,21 @@ public function testSummary() $result = $this->panel->summary(); $this->assertMatchesRegularExpression('/\d+ \\/ \d+(\.\d+)? ms/', $result); } + + /** + * Testing a simple connection (no set/getLogger on driver). + * + * @return void + */ + public function testWithSimpleConnection() + { + ConnectionManager::setConfig('simple', [ + 'className' => 'DebugKit\TestApp\Stub\SimpleConnectionStub', + ]); + + $this->panel->addConnection('simple'); // should not throw an error + $this->assertTrue(true); + + ConnectionManager::drop('simple'); + } } diff --git a/tests/test_app/Stub/SimpleConnectionStub.php b/tests/test_app/Stub/SimpleConnectionStub.php new file mode 100644 index 000000000..0f3a6948c --- /dev/null +++ b/tests/test_app/Stub/SimpleConnectionStub.php @@ -0,0 +1,37 @@ +