From 7ae79d61ef1a249f5835ac99529c1eab46a589b1 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 9 Apr 2021 21:03:43 +0200 Subject: [PATCH] imap_search bugfix --- core/Api/MailAPI.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/Api/MailAPI.class.php b/core/Api/MailAPI.class.php index 6bac05a..a266ee6 100644 --- a/core/Api/MailAPI.class.php +++ b/core/Api/MailAPI.class.php @@ -246,10 +246,11 @@ namespace Api\Mail { return $boxes; } - private function runSearch($mbox, string $searchCriteria, ?\DateTime $lastSyncDateTime, &$messages) { + private function runSearch($mbox, string $searchCriteria, ?\DateTime $lastSyncDateTime, array $messageIds, array &$messages) { $result = @imap_search($mbox, $searchCriteria); if ($result === false) { - return $this->createError("Could not run search: " . imap_last_error()); + $err = imap_last_error(); // might return false, if not messages were found, so we can just abort without throwing an error + return empty($err) ? true : $this->createError("Could not run search: $err"); } foreach ($result as $msgNo) { @@ -348,7 +349,7 @@ namespace Api\Mail { $messages = []; foreach ($boxes as $box) { imap_reopen($mbox, $box); - if (!$this->runSearch($mbox, $searchCriteria, $lastSyncDateTime, $messages)) { + if (!$this->runSearch($mbox, $searchCriteria, $lastSyncDateTime, $messageIds,$messages)) { return false; } }