From b4b073e8a1f12751be8ae0c97a8b182e7fa25331 Mon Sep 17 00:00:00 2001 From: michalsn Date: Thu, 7 May 2026 16:09:24 +0200 Subject: [PATCH 1/2] fix: support third-party loggers in toolbar logs collector --- system/Debug/Toolbar/Collectors/Logs.php | 8 ++++++-- .../system/Debug/Toolbar/Collectors/LogsTest.php | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/system/Debug/Toolbar/Collectors/Logs.php b/system/Debug/Toolbar/Collectors/Logs.php index f9fdabecbff1..92562e81e629 100644 --- a/system/Debug/Toolbar/Collectors/Logs.php +++ b/system/Debug/Toolbar/Collectors/Logs.php @@ -92,9 +92,13 @@ protected function collectLogs() return $this->data; } - $cache = service('logger')->logCache; + $logger = service('logger'); - $this->data = $cache ?? []; + if (! property_exists($logger, 'logCache')) { + return $this->data; + } + + $this->data = $logger->logCache; return $this->data; } diff --git a/tests/system/Debug/Toolbar/Collectors/LogsTest.php b/tests/system/Debug/Toolbar/Collectors/LogsTest.php index c239d0d422ba..a89fc878260c 100644 --- a/tests/system/Debug/Toolbar/Collectors/LogsTest.php +++ b/tests/system/Debug/Toolbar/Collectors/LogsTest.php @@ -18,6 +18,8 @@ use Config\Logger as LoggerConfig; use Config\Services; use PHPUnit\Framework\Attributes\Group; +use Psr\Log\AbstractLogger; +use Stringable; /** * @internal @@ -68,4 +70,18 @@ public function testNotEmpty(): void $collector = new Logs(); $this->assertFalse($collector->isEmpty()); } + + public function testEmptyWithThirdPartyLogger(): void + { + Services::injectMock('logger', new class () extends AbstractLogger { + public function log($level, string|Stringable $message, array $context = []): void + { + } + }); + + $collector = new Logs(); + + $this->assertTrue($collector->isEmpty()); + $this->assertSame(['logs' => []], $collector->display()); + } } From 7c53bca06a4a3bdd02964bbb9fe31b828daa49fb Mon Sep 17 00:00:00 2001 From: michalsn Date: Thu, 7 May 2026 16:13:02 +0200 Subject: [PATCH 2/2] add changelog --- user_guide_src/source/changelogs/v4.7.3.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelogs/v4.7.3.rst b/user_guide_src/source/changelogs/v4.7.3.rst index 06418cf9e5e8..e3600a814369 100644 --- a/user_guide_src/source/changelogs/v4.7.3.rst +++ b/user_guide_src/source/changelogs/v4.7.3.rst @@ -42,6 +42,7 @@ Bugs Fixed - **Common:** Fixed a bug where the ``command()`` helper function did not properly clean up output buffers, which could lead to risky tests when exceptions were thrown. - **Database:** Fixed a bug where the SQLSRV driver's decrement method was adding instead of subtracting the decrement value when ``$castTextToInt`` was false. - **Kint:** Fixed a bug where stale Content Security Policy nonces were reused in worker mode, causing browser CSP violations for Debug Toolbar assets. +- **Toolbar:** Fixed a bug where the Logs collector raised an undefined property error when using a third-party PSR-3 logger. - **Time:** Fixed a bug where ``Time::createFromTimestamp()`` could fail for microsecond timestamps when ``LC_NUMERIC`` used a comma decimal separator. - **Validation:** Fixed a bug where ``Validation::getValidated()`` dropped fields whose validated value was explicitly ``null``.