From 64c924ea06afa1eec463078a5d05fc908c12d10d Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 15 Oct 2013 03:22:09 -0400
Subject: [PATCH] Fix regression where wrong set of message identifiers was used in sql query that was supposed to fetch list of messages from cache

---
 program/lib/Roundcube/rcube_imap_cache.php |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/program/lib/Roundcube/rcube_imap_cache.php b/program/lib/Roundcube/rcube_imap_cache.php
index 445d463..a816654 100644
--- a/program/lib/Roundcube/rcube_imap_cache.php
+++ b/program/lib/Roundcube/rcube_imap_cache.php
@@ -327,7 +327,6 @@
             return array();
         }
 
-        $msgs   = array_flip($msgs);
         $result = array();
 
         if ($this->mode & self::MODE_MESSAGE) {
@@ -340,6 +339,8 @@
                     ." AND uid IN (".$this->db->array2list($msgs, 'integer').")",
                 $this->userid, $mailbox);
 
+            $msgs = array_flip($msgs);
+
             while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
                 $uid          = intval($sql_arr['uid']);
                 $result[$uid] = $this->build_message($sql_arr);
@@ -351,11 +352,13 @@
                     unset($msgs[$uid]);
                 }
             }
+
+            $msgs = array_flip($msgs);
         }
 
         // Fetch not found messages from IMAP server
         if (!empty($msgs)) {
-            $messages = $this->imap->fetch_headers($mailbox, array_keys($msgs), false, true);
+            $messages = $this->imap->fetch_headers($mailbox, $msgs, false, true);
 
             // Insert to DB and add to result list
             if (!empty($messages)) {

--
Gitblit v1.9.1