Skip to content

Commit a3a533a

Browse files
fix(imap): avoid Horde's LIST-STATUS optimization for STATUS
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent a5bb4b6 commit a3a533a

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

lib/IMAP/FolderMapper.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,9 @@ public function fetchFolderAcls(array $folders,
127127
*/
128128
public function getFoldersStatusAsObject(Horde_Imap_Client_Socket $client,
129129
array $mailboxes): array {
130-
$multiStatus = $client->status($mailboxes);
131-
132130
$statuses = [];
133-
foreach ($multiStatus as $mailbox => $status) {
131+
foreach ($mailboxes as $mailbox) {
132+
$status = $client->status($mailbox);
134133
try {
135134
if (!isset($status['messages'], $status['unseen'])) {
136135
throw new ServiceException('Could not fetch stats of mailbox: ' . $mailbox);

tests/Unit/IMAP/FolderMapperTest.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,10 @@ public function testGetFoldersStatusAsObject(): void {
209209
$client = $this->createMock(Horde_Imap_Client_Socket::class);
210210
$client->expects($this->once())
211211
->method('status')
212-
->with(['INBOX'])
212+
->with('INBOX')
213213
->willReturn([
214-
'INBOX' => [
215-
'messages' => 123,
216-
'unseen' => 2,
217-
],
214+
'messages' => 123,
215+
'unseen' => 2,
218216
]);
219217

220218
$stats = $this->mapper->getFoldersStatusAsObject($client, ['INBOX']);
@@ -228,25 +226,15 @@ public function testGetFoldersStatusAsObjectNullStats(): void {
228226
$client = $this->createMock(Horde_Imap_Client_Socket::class);
229227
$client->expects($this->once())
230228
->method('status')
231-
->with(['INBOX'])
229+
->with('INBOX')
232230
->willReturn([
233-
'INBOX' => [
234-
'messages' => null,
235-
'unseen' => 2,
236-
],
237-
'Company' => [
238-
'messages' => 123,
239-
'unseen' => 2,
240-
],
231+
'messages' => null,
232+
'unseen' => 2,
241233
]);
242234

243235
$stats = $this->mapper->getFoldersStatusAsObject($client, ['INBOX']);
244236

245237
self::assertArrayNotHasKey('INBOX', $stats);
246-
self::assertArrayHasKey('Company', $stats);
247-
$expected = new MailboxStats(123, 2);
248-
self::assertEquals($expected, $stats['Company']);
249-
250238
}
251239

252240
public function testDetectSpecialUseFromAttributes() {

0 commit comments

Comments
 (0)