From 422359b069d3ae719f20552382d997b364bcc434 Mon Sep 17 00:00:00 2001 From: Sam James Date: Wed, 15 Jul 2026 22:40:58 +0100 Subject: [PATCH] fix: master Enabled toggle not disabling PageBuilder preload scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BlockToHtmlAfter used && instead of || when checking the two config flags, so it only skipped when BOTH isEnabled() and isPageBuilderPreloadEnabled() were false. Turning the module's master "Enabled" switch off had no effect as long as the (default-on) pagebuilder_content toggle was left enabled — every other observer in the module already uses the correct || guard. --- Observer/View/BlockToHtmlAfter.php | 2 +- .../Observer/View/BlockToHtmlAfterTest.php | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Observer/View/BlockToHtmlAfter.php b/Observer/View/BlockToHtmlAfter.php index e8c7403..ee8dcad 100644 --- a/Observer/View/BlockToHtmlAfter.php +++ b/Observer/View/BlockToHtmlAfter.php @@ -19,7 +19,7 @@ public function __construct( */ public function execute(Observer $observer) { - if (!$this->config->isEnabled() && !$this->config->isPageBuilderPreloadEnabled()) { + if (!$this->config->isEnabled() || !$this->config->isPageBuilderPreloadEnabled()) { return; } diff --git a/Test/Unit/Observer/View/BlockToHtmlAfterTest.php b/Test/Unit/Observer/View/BlockToHtmlAfterTest.php index 879cd5d..b916315 100644 --- a/Test/Unit/Observer/View/BlockToHtmlAfterTest.php +++ b/Test/Unit/Observer/View/BlockToHtmlAfterTest.php @@ -47,7 +47,6 @@ protected function setUp(): void public function testDoesNothingWhenBothConfigsDisabled(): void { - // Note: The condition is: if (!isEnabled && !isPageBuilderPreloadEnabled) $this->configMock->method('isEnabled')->willReturn(false); $this->configMock->method('isPageBuilderPreloadEnabled')->willReturn(false); @@ -158,34 +157,32 @@ public function testIgnoresImagesWithoutPreloadAttribute(): void $this->subject->execute($this->observerMock); } - public function testExecutesWhenOnlyModuleEnabled(): void + public function testDoesNothingWhenOnlyModuleEnabled(): void { + // Master 'Enabled' switch alone is not sufficient - the pagebuilder_content + // toggle must also be on, matching every other observer in this module. $this->configMock->method('isEnabled')->willReturn(true); $this->configMock->method('isPageBuilderPreloadEnabled')->willReturn(false); $html = ''; $this->transport->setHtml($html); - $preloadMock = $this->createMock(Preload::class); - $this->preloadFactoryMock->method('create')->willReturn($preloadMock); - - $this->linkStoreMock->expects($this->once())->method('add'); + $this->linkStoreMock->expects($this->never())->method('add'); $this->subject->execute($this->observerMock); } - public function testExecutesWhenOnlyPageBuilderPreloadEnabled(): void + public function testDoesNothingWhenOnlyPageBuilderPreloadEnabled(): void { + // pagebuilder_content toggle alone is not sufficient if the master + // 'Enabled' switch is off - it must act as a full kill-switch. $this->configMock->method('isEnabled')->willReturn(false); $this->configMock->method('isPageBuilderPreloadEnabled')->willReturn(true); $html = ''; $this->transport->setHtml($html); - $preloadMock = $this->createMock(Preload::class); - $this->preloadFactoryMock->method('create')->willReturn($preloadMock); - - $this->linkStoreMock->expects($this->once())->method('add'); + $this->linkStoreMock->expects($this->never())->method('add'); $this->subject->execute($this->observerMock); }