From a84c42f7a76be633a3086a07069b0b99267cb53f Mon Sep 17 00:00:00 2001 From: Yurii Date: Mon, 2 Feb 2026 11:40:08 +0200 Subject: [PATCH] fix imap uid fetch --- .../Mail/Account/Storage/DirectoryTreeStorage.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/application/Espo/Core/Mail/Account/Storage/DirectoryTreeStorage.php b/application/Espo/Core/Mail/Account/Storage/DirectoryTreeStorage.php index 534e09f5be..c9d74b7000 100644 --- a/application/Espo/Core/Mail/Account/Storage/DirectoryTreeStorage.php +++ b/application/Espo/Core/Mail/Account/Storage/DirectoryTreeStorage.php @@ -128,7 +128,6 @@ class DirectoryTreeStorage implements Storage } /** - * @todo Test. * @inheritDoc * @noinspection PhpRedundantCatchClauseInspection */ @@ -156,6 +155,13 @@ class DirectoryTreeStorage implements Storage throw new ImapError($e->getMessage(), previous: $e); } + // May return wrong items. Do not return one with matching id. + $output = array_filter($output, fn ($it) => $it > $id); + $output = array_values($output); + + // Otherwise, it's in reverse order. + sort($output); + return $output; } @@ -188,6 +194,9 @@ class DirectoryTreeStorage implements Storage throw new ImapError($e->getMessage(), previous: $e); } + // Otherwise, it's in reverse order. + sort($output); + return $output; }