From 545559307e2cf7d986af5993f7d3ea0fc30a8386 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 11 Jun 2013 03:28:33 -0400
Subject: [PATCH] Make sure to use threads result cached in-memory for correct folder

---
 program/lib/Roundcube/rcube_imap.php |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index 257efbb..39057a8 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -812,20 +812,22 @@
             return $mcache->get_thread($folder);
         }
 
-        if (empty($this->icache['threads'])) {
-            if (!$this->check_connection()) {
-                return new rcube_result_thread();
+        if (!empty($this->icache['threads'])) {
+            if ($this->icache['threads']->get_parameters('MAILBOX') == $folder) {
+                return $this->icache['threads'];
             }
-
-            // get all threads
-            $result = $this->conn->thread($folder, $this->threading,
-                $this->options['skip_deleted'] ? 'UNDELETED' : '', true);
-
-            // add to internal (fast) cache
-            $this->icache['threads'] = $result;
         }
 
-        return $this->icache['threads'];
+        if (!$this->check_connection()) {
+            return new rcube_result_thread();
+        }
+
+        // get all threads
+        $result = $this->conn->thread($folder, $this->threading,
+            $this->options['skip_deleted'] ? 'UNDELETED' : '', true);
+
+        // add to internal (fast) cache
+        return $this->icache['threads'] = $result;
     }
 
 

--
Gitblit v1.9.1