From f1f0582dbae2173a8c5b120f6589f3ca786bda12 Mon Sep 17 00:00:00 2001 From: Phil Bates Date: Fri, 15 May 2026 13:32:22 +0100 Subject: [PATCH] Fix AbstractProcessingHandler::handle() to call getBubble() instead of reading \$bubble directly Subclasses that override getBubble() to dynamically control bubbling behaviour were bypassed because handle() read the protected \$bubble property directly. Switching to !$this->getBubble() ensures the getter is always respected. Regression test added to AbstractProcessingHandlerTest. Relates to symfony/symfony#64207 Co-Authored-By: Claude Sonnet 4.6 --- .../Handler/AbstractProcessingHandler.php | 2 +- .../Handler/AbstractProcessingHandlerTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Monolog/Handler/AbstractProcessingHandler.php b/src/Monolog/Handler/AbstractProcessingHandler.php index de13a76be..78bec3e6a 100644 --- a/src/Monolog/Handler/AbstractProcessingHandler.php +++ b/src/Monolog/Handler/AbstractProcessingHandler.php @@ -43,7 +43,7 @@ public function handle(LogRecord $record): bool $this->write($record); - return false === $this->bubble; + return !$this->getBubble(); } /** diff --git a/tests/Monolog/Handler/AbstractProcessingHandlerTest.php b/tests/Monolog/Handler/AbstractProcessingHandlerTest.php index 9d7e29552..14d24c812 100644 --- a/tests/Monolog/Handler/AbstractProcessingHandlerTest.php +++ b/tests/Monolog/Handler/AbstractProcessingHandlerTest.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Level; +use Monolog\LogRecord; use Monolog\Processor\WebProcessor; use Monolog\Formatter\LineFormatter; @@ -89,6 +90,23 @@ public function testProcessRecord() $this->assertEquals(6, \count($handledRecord['extra'])); } + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleRespectsGetBubbleOverride(): void + { + $handler = new class(Level::Debug, false) extends AbstractProcessingHandler { + protected function write(LogRecord $record): void {} + + public function getBubble(): bool + { + return true; + } + }; + + $this->assertFalse($handler->handle($this->getRecord())); + } + /** * @covers Monolog\Handler\ProcessableHandlerTrait::pushProcessor * @covers Monolog\Handler\ProcessableHandlerTrait::popProcessor