From 36ed9d7ec69a0e774c13ed4c583b8674eee4fb98 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 27 Oct 2010 02:53:11 -0400
Subject: [PATCH] - Improve performance of rcube_imap_generic::countMessages() using STATUS instead of SELECT

---
 program/include/rcube_imap_generic.php |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 41240a2..2171e5d 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -944,11 +944,16 @@
 		    $this->selected = '';
 	    }
 
-	    $this->select($mailbox);
 	    if ($this->selected == $mailbox) {
 		    return $this->data['EXISTS'];
 	    }
 
+        // Try STATUS, should be faster
+        $counts = $this->status($mailbox, array('MESSAGES'));
+        if (is_array($counts)) {
+            return (int) $counts['MESSAGES'];
+        }
+
         return false;
     }
 

--
Gitblit v1.9.1