summaryrefslogtreecommitdiff
path: root/roundcubemail/program/include/rcube_imap.php
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-10-20 18:42:45 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-10-20 18:42:45 +0000
commitc6fe3f23df35d4f85fc43c8dbdb9b6938563b2f1 (patch)
tree000f8275b621b69f367c0c7b47d49da581fb7bfa /roundcubemail/program/include/rcube_imap.php
parente829400a8b56f30d98009aa2aa4a499613903768 (diff)
- Improve performance of messages counting using ESEARCH extension (RFC4731)
git-svn-id: https://svn.roundcube.net/trunk@4118 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/rcube_imap.php')
-rw-r--r--roundcubemail/program/include/rcube_imap.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/roundcubemail/program/include/rcube_imap.php b/roundcubemail/program/include/rcube_imap.php
index 5d90fe41f..4bf7cac88 100644
--- a/roundcubemail/program/include/rcube_imap.php
+++ b/roundcubemail/program/include/rcube_imap.php
@@ -539,19 +539,26 @@ class rcube_imap
// use SEARCH for message counting
else if ($this->skip_deleted) {
$search_str = "ALL UNDELETED";
+ $keys = array('COUNT');
+ $need_uid = false;
- // get message count and store in cache
- if ($mode == 'UNSEEN')
+ if ($mode == 'UNSEEN') {
$search_str .= " UNSEEN";
- // get message count using SEARCH
+ }
+ else if ($status) {
+ $keys[] = 'MAX';
+ $need_uid = true;
+ }
+
+ // get message count using (E)SEARCH
// not very performant but more precise (using UNDELETED)
- $index = $this->conn->search($mailbox, $search_str);
+ $index = $this->conn->search($mailbox, $search_str, $need_uid, $keys);
- $count = is_array($index) ? count($index) : 0;
+ $count = is_array($index) ? $index['COUNT'] : 0;
if ($mode == 'ALL' && $status) {
$this->set_folder_stats($mailbox, 'cnt', $count);
- $this->set_folder_stats($mailbox, 'maxuid', $index ? $this->_id2uid(max($index), $mailbox) : 0);
+ $this->set_folder_stats($mailbox, 'maxuid', is_array($index) ? $index['MAX'] : 0);
}
}
else {