From 0ca75d488059b685ae344dbb629aa935dce3ab79 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 11 Apr 2014 13:28:52 -0400
Subject: [PATCH] Fix messages index cache update under some conditions (e.g. proxy) (#1489756)

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

diff --git a/CHANGELOG b/CHANGELOG
index 8cdd1c9..8e5a47d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
 - Fix bug where "With attachment" option in search filter wasn't selected after return from mail view (#1489774)
 - Fix "washing" of unicoded style attributes (#1489777)
 - Fix unintentional redirect from compose page in Webkit browsers (#1489789)
+- Fix messages index cache update under some conditions (e.g. proxy) (#1489756)
 
 RELEASE 1.0.0
 -------------
diff --git a/program/lib/Roundcube/rcube_imap_cache.php b/program/lib/Roundcube/rcube_imap_cache.php
index 0c3edea..e49e778 100644
--- a/program/lib/Roundcube/rcube_imap_cache.php
+++ b/program/lib/Roundcube/rcube_imap_cache.php
@@ -171,7 +171,7 @@
         // Seek in internal cache
         if (array_key_exists('index', $this->icache[$mailbox])) {
             // The index was fetched from database already, but not validated yet
-            if (!array_key_exists('object', $this->icache[$mailbox]['index'])) {
+            if (empty($this->icache[$mailbox]['index']['validated'])) {
                 $index = $this->icache[$mailbox]['index'];
             }
             // We've got a valid index
@@ -248,6 +248,7 @@
         }
 
         $this->icache[$mailbox]['index'] = array(
+            'validated'  => true,
             'object'     => $data,
             'sort_field' => $sort_field,
             'modseq'     => !empty($index['modseq']) ? $index['modseq'] : $mbox_data['HIGHESTMODSEQ']
@@ -890,6 +891,8 @@
             return false;
         }
 
+        $index['validated'] = true;
+
         // Get mailbox data (UIDVALIDITY, counters, etc.) for status check
         $mbox_data = $this->imap->folder_data($mailbox);
 

--
Gitblit v1.9.1