From fc1a0a1f6529cfcfb1a03b58c78fdd0dd90e109a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Jul 2017 13:27:40 +0200 Subject: [PATCH] Fix bug where messages count was not updated after delete when imap_cache is set (#5872) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_imap.php | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 416d248f3..20be09fba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -49,6 +49,7 @@ CHANGELOG Roundcube Webmail - Fix PHP 7.2 warnings on count() use (#5845) - Fix bug where Chrome could not upload the same file that was selected before (#5854) - Fix duplicate messages on the list after deleting messages on the next to the last page (#5862) +- Fix bug where messages count was not updated after delete when imap_cache is set (#5872) RELEASE 1.3.0 ------------- diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index 906d8dc08..8b96b3024 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -2495,13 +2495,12 @@ class rcube_imap extends rcube_storage // clear cached counters if ($flag == 'SEEN' || $flag == 'UNSEEN') { - $this->clear_messagecount($folder, 'SEEN'); - $this->clear_messagecount($folder, 'UNSEEN'); + $this->clear_messagecount($folder, array('SEEN', 'UNSEEN')); } else if ($flag == 'DELETED' || $flag == 'UNDELETED') { - $this->clear_messagecount($folder, 'DELETED'); - // remove cached messages + $this->clear_messagecount($folder, array('ALL', 'THREADS')); if ($this->options['skip_deleted']) { + // remove cached messages $this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids)); } } @@ -4415,13 +4414,15 @@ class rcube_imap extends rcube_storage /** * Remove messagecount of a specific folder from cache */ - protected function clear_messagecount($folder, $mode=null) + protected function clear_messagecount($folder, $mode = array()) { $a_folder_cache = $this->get_cache('messagecount'); if (is_array($a_folder_cache[$folder])) { - if ($mode) { - unset($a_folder_cache[$folder][$mode]); + if (!empty($mode)) { + foreach ((array) $mode as $key) { + unset($a_folder_cache[$folder][$key]); + } } else { unset($a_folder_cache[$folder]);