From a7d269253f99d92f7307f13b906bea46c322a59f Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 12 May 2015 03:10:10 -0400
Subject: [PATCH] Workaround possible issue where some keys were ignored when deleting cached entries by key name prefix and keys index is in inconsistent state (does not contain all keys)

---
 program/lib/Roundcube/rcube_cache.php |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/program/lib/Roundcube/rcube_cache.php b/program/lib/Roundcube/rcube_cache.php
index 303abda..36b5504 100644
--- a/program/lib/Roundcube/rcube_cache.php
+++ b/program/lib/Roundcube/rcube_cache.php
@@ -403,7 +403,13 @@
             }
             // Remove keys by name prefix
             else if ($prefix_mode) {
-                foreach ($this->index as $k) {
+                // handle data inconsistency: it may happen that index
+                // contains not all existing cache entries, here we could
+                // handle at least these that were used before the index was read
+                $index = array_merge($this->index, array_keys($this->cache));
+                $index = array_unique($index);
+
+                foreach ($index as $k) {
                     if (strpos($k, $key) === 0) {
                         $this->delete_record($k);
                     }

--
Gitblit v1.9.1