From 102679362f76ae1187610fade377e7ebc28df229 Mon Sep 17 00:00:00 2001 From: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com> Date: Thu, 3 Sep 2026 09:53:15 +0200 Subject: [PATCH] fix(imap): pass through $loadBody in ImapMessageConnector::fetchMessages findByIds() was always called with a hardcoded true for the load-body argument, ignoring the connector's own $loadBody parameter. Callers that explicitly request loadBody=false (e.g. for lightweight metadata-only fetches) silently got the full message body anyway. Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com> --- lib/IMAP/ImapMessageConnector.php | 2 +- tests/Unit/IMAP/ImapMessageConnectorTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/IMAP/ImapMessageConnector.php b/lib/IMAP/ImapMessageConnector.php index 27380a2ddb..0e10b80f18 100644 --- a/lib/IMAP/ImapMessageConnector.php +++ b/lib/IMAP/ImapMessageConnector.php @@ -92,7 +92,7 @@ public function fetchMessages(Account $account, Mailbox $mailbox, bool $loadBody $mailbox->getName(), $uids, $account->getUserId(), - true + $loadBody ); } catch (DoesNotExistException|Horde_Mime_Exception|Horde_Imap_Client_Exception $e) { throw new ServiceException('Could not load messages: ' . $e->getMessage(), $e->getCode(), $e); diff --git a/tests/Unit/IMAP/ImapMessageConnectorTest.php b/tests/Unit/IMAP/ImapMessageConnectorTest.php index 224f098659..0aacbd0a53 100644 --- a/tests/Unit/IMAP/ImapMessageConnectorTest.php +++ b/tests/Unit/IMAP/ImapMessageConnectorTest.php @@ -180,4 +180,20 @@ public function testIsPermflagsEnabledLogsOutClientOnSuccess(): void { self::assertTrue($result); } + + public function testFetchMessagesPassesThroughLoadBody(): void { + $mailbox = new Mailbox(); + $mailbox->setName('INBOX'); + $message = new Message(); + $message->setUid(1); + $this->account->method('getUserId') + ->willReturn('user123'); + + $this->imapMessageMapper->expects(self::once()) + ->method('findByIds') + ->with($this->client, 'INBOX', [1], 'user123', false) + ->willReturn([]); + + $this->connector->fetchMessages($this->account, $mailbox, false, $message); + } }