From 48a954e07798cdcceafeb35d21ef88e435e1358f Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sat, 28 May 2022 23:38:41 +0200 Subject: [PATCH] Bugfix: ImapContactsSuggestions error on empty $aUids --- .../ImapContactsSuggestions.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/imap-contacts-suggestions/ImapContactsSuggestions.php b/plugins/imap-contacts-suggestions/ImapContactsSuggestions.php index 78fc40f65..a39202ace 100644 --- a/plugins/imap-contacts-suggestions/ImapContactsSuggestions.php +++ b/plugins/imap-contacts-suggestions/ImapContactsSuggestions.php @@ -29,11 +29,13 @@ class ImapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges ); $aResult = []; - foreach ($oImapClient->Fetch(['BODY.PEEK[HEADER.FIELDS (FROM)]'], \implode(',', $aUids), true) as $oFetchResponse) { - $oHeaders = new \MailSo\Mime\HeaderCollection($oFetchResponse->GetHeaderFieldsValue()); - $oFrom = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, true); - foreach ($oFrom as $oMail) { - $aResult[] = [$oMail->GetEmail(), $oMail->GetDisplayName()]; + if ($aUids) { + foreach ($oImapClient->Fetch(['BODY.PEEK[HEADER.FIELDS (FROM)]'], \implode(',', $aUids), true) as $oFetchResponse) { + $oHeaders = new \MailSo\Mime\HeaderCollection($oFetchResponse->GetHeaderFieldsValue()); + $oFrom = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, true); + foreach ($oFrom as $oMail) { + $aResult[] = [$oMail->GetEmail(), $oMail->GetDisplayName()]; + } } }