Mercurial > hg > rc2
diff program/lib/Roundcube/rcube_imap.php @ 16:1866b439e6d3
Slowly cleaning up more php8 Warnings/deprecations
| author | Charlie Root |
|---|---|
| date | Mon, 06 Oct 2025 10:34:51 -0400 |
| parents | 85a746e95663 |
| children | dd5ed6ef69c9 |
line wrap: on
line diff
--- a/program/lib/Roundcube/rcube_imap.php Sat Sep 20 12:16:50 2025 -0400 +++ b/program/lib/Roundcube/rcube_imap.php Mon Oct 06 10:34:51 2025 -0400 @@ -663,50 +663,51 @@ // of all messages in a folder also when search is active and with // any skip_deleted setting - $a_folder_cache = $this->get_cache('messagecount'); - - // return cached value - if (!$force && is_array($a_folder_cache[$folder]) && isset($a_folder_cache[$folder][$mode])) { + if ($this->caching) { + $a_folder_cache = $this->get_cache('messagecount'); + + // return cached value + if (!$force && is_array($a_folder_cache[$folder]) && isset($a_folder_cache[$folder][$mode])) { return $a_folder_cache[$folder][$mode]; - } - - if (!is_array($a_folder_cache[$folder])) { + } + + if (!is_array($a_folder_cache[$folder])) { $a_folder_cache[$folder] = array(); - } - - if ($mode == 'THREADS') { + } + } + if ($mode == 'THREADS') { $res = $this->threads($folder); $count = $res->count(); if ($status) { - $msg_count = $res->count_messages(); - $this->set_folder_stats($folder, 'cnt', $msg_count); - $this->set_folder_stats($folder, 'maxuid', $msg_count ? $this->id2uid($msg_count, $folder) : 0); + $msg_count = $res->count_messages(); + $this->set_folder_stats($folder, 'cnt', $msg_count); + $this->set_folder_stats($folder, 'maxuid', $msg_count ? $this->id2uid($msg_count, $folder) : 0); } - } - // Need connection here - else if (!$this->check_connection()) { + } + // Need connection here + else if (!$this->check_connection()) { return 0; - } - // RECENT count is fetched a bit different - else if ($mode == 'RECENT') { + } + // RECENT count is fetched a bit different + else if ($mode == 'RECENT') { $count = $this->conn->countRecent($folder); - } - // use SEARCH for message counting - else if ($mode != 'EXISTS' && !empty($this->options['skip_deleted'])) { + } + // use SEARCH for message counting + else if ($mode != 'EXISTS' && !empty($this->options['skip_deleted'])) { $search_str = "ALL UNDELETED"; $keys = array('COUNT'); if ($mode == 'UNSEEN') { - $search_str .= " UNSEEN"; + $search_str .= " UNSEEN"; } else { - if ($this->messages_caching) { - $keys[] = 'ALL'; - } - if ($status) { - $keys[] = 'MAX'; - } + if ($this->messages_caching) { + $keys[] = 'ALL'; + } + if ($status) { + $keys[] = 'MAX'; + } } // @TODO: if $mode == 'ALL' we could try to use cache index here @@ -717,32 +718,34 @@ $count = $index->count(); if ($mode == 'ALL') { - // Cache index data, will be used in index_direct() - $this->icache['undeleted_idx'] = $index; - - if ($status) { - $this->set_folder_stats($folder, 'cnt', $count); - $this->set_folder_stats($folder, 'maxuid', $index->max()); - } + // Cache index data, will be used in index_direct() + $this->icache['undeleted_idx'] = $index; + + if ($status) { + $this->set_folder_stats($folder, 'cnt', $count); + $this->set_folder_stats($folder, 'maxuid', $index->max()); + } } - } - else { + } + else { if ($mode == 'UNSEEN') { - $count = $this->conn->countUnseen($folder); + $count = $this->conn->countUnseen($folder); } else { - $count = $this->conn->countMessages($folder); - if ($status && $mode == 'ALL') { - $this->set_folder_stats($folder, 'cnt', $count); - $this->set_folder_stats($folder, 'maxuid', $count ? $this->id2uid($count, $folder) : 0); - } + $count = $this->conn->countMessages($folder); + if ($status && $mode == 'ALL') { + $this->set_folder_stats($folder, 'cnt', $count); + $this->set_folder_stats($folder, 'maxuid', $count ? $this->id2uid($count, $folder) : 0); + } } - } - - $a_folder_cache[$folder][$mode] = (int)$count; - - // write back to cache - $this->update_cache('messagecount', $a_folder_cache); + } + + if ($this->caching) { + $a_folder_cache[$folder][$mode] = (int)$count; + + // write back to cache + $this->update_cache('messagecount', $a_folder_cache); + } return (int)$count; } @@ -4089,7 +4092,9 @@ public function update_cache($key, $data) { if ($cache = $this->get_cache_engine()) { + $cache->set($key, $data); + rcube::write_log('mail',"cache " . !(!$cache) . " for " . $key); } } @@ -4347,7 +4352,7 @@ */ protected function set_messagecount($folder, $mode, $increment) { - if (!is_numeric($increment)) { + if (!is_numeric($increment) || !$this->caching) { return false; }
