Skip to content

Commit

Permalink
fixup! perf(imap): FETCH only flags for partial message updates
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed May 4, 2023
1 parent a3de319 commit cd68c2b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/IMAP/MessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public function findFlagsByIds(Horde_Imap_Client_Base $client,
string $userId,
bool $loadBody = false): array {
$query = new Horde_Imap_Client_Fetch_Query();
$query->uid();
$query->flags();

return $this->findByQuery($ids, $query, $mailbox, $client, $loadBody, $userId);
Expand Down Expand Up @@ -331,11 +332,11 @@ private function findByQuery(array|Horde_Imap_Client_Ids $ids, Horde_Imap_Client
}

$fetchResults = array_values(array_filter($fetchResults, static function (Horde_Imap_Client_Data_Fetch $fetchResult) {
return $fetchResult->exists(Horde_Imap_Client::FETCH_ENVELOPE);
return $fetchResult->exists(Horde_Imap_Client::FETCH_UID);
}));

if (empty($fetchResults)) {
$this->logger->debug("findByIds in $mailbox got " . count($ids) . " UIDs but found none");
$this->logger->debug("findByQuery in $mailbox got " . count($ids) . " UIDs but found none");
} else {
$minFetched = $fetchResults[0]->getUid();
$maxFetched = $fetchResults[count($fetchResults) - 1]->getUid();
Expand All @@ -344,7 +345,7 @@ private function findByQuery(array|Horde_Imap_Client_Ids $ids, Horde_Imap_Client
} else {
$range = 'literals';
}
$this->logger->debug("findByIds in $mailbox got " . count($ids) . " UIDs ($range) and found " . count($fetchResults) . ". minFetched=$minFetched maxFetched=$maxFetched");
$this->logger->debug("findByQuery in $mailbox got " . count($ids) . " UIDs ($range) and found " . count($fetchResults) . ". minFetched=$minFetched maxFetched=$maxFetched");
}

return array_map(function (Horde_Imap_Client_Data_Fetch $fetchResult) use ($client, $mailbox, $loadBody, $userId) {
Expand Down

0 comments on commit cd68c2b

Please sign in to comment.