From 91ec0a0559b907af5c125face53440675e2323c9 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 10 May 2009 04:59:39 -0400
Subject: [PATCH] - speed up remove_message_cache() by using message uid instead of idx

---
 program/include/rcube_imap.php |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 4073c8a..3ff0f3f 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -796,7 +796,7 @@
           {
           // delete from cache
           if ($cache_index[$headers->id] && $cache_index[$headers->id] == $headers->uid)
-            $this->remove_message_cache($cache_key, $headers->id);
+            $this->remove_message_cache($cache_key, $headers->uid);
 
           $deleted_count++;
           continue;
@@ -927,7 +927,7 @@
       // other message at this position
       if (isset($cache_index[$id]))
         {
-        $this->remove_message_cache($cache_key, $id);
+        $this->remove_message_cache($cache_key, $cache_index[$id]);
         unset($cache_index[$id]);
         }
         
@@ -941,7 +941,7 @@
     if (!empty($cache_index))
       {
       foreach ($cache_index as $id => $uid)
-        $this->remove_message_cache($cache_key, $id);
+        $this->remove_message_cache($cache_key, $uid);
       }
     }
 
@@ -1436,7 +1436,7 @@
     if ($print)
       {
       $mode = $o_part->encoding == 'base64' ? 3 : ($o_part->encoding == 'quoted-printable' ? 1 : 2);
-      $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, $mode);
+      $body = iil_C_HandlePartBody($this->conn, $this->mailbox, '', $part, $mode);
       
       // we have to decode the part manually before printing
       if ($mode == 1)
@@ -1567,7 +1567,7 @@
       {
       foreach ($uids as $uid)
         if ($cached_headers = $this->get_cached_message($cache_key, $uid))
-          $this->remove_message_cache($cache_key, $this->_uid2id($uid));
+          $this->remove_message_cache($cache_key, $uid);
 
       // close and re-open connection
       // this prevents connection problems with Courier 
@@ -2430,7 +2430,7 @@
   /**
    * @access private
    */
-  function remove_message_cache($key, $index)
+  function remove_message_cache($key, $uid)
     {
     if (!$this->caching_enabled)
       return;
@@ -2439,10 +2439,10 @@
       "DELETE FROM ".get_table_name('messages')."
        WHERE  user_id=?
        AND    cache_key=?
-       AND    idx=?",
+       AND    uid=?",
       $_SESSION['user_id'],
       $key,
-      $index);
+      $uid);
     }
 
   /**

--
Gitblit v1.9.1