From 229d31e90e250bffaf77e823118210f709a574a2 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 6 Jan 2014 17:08:02 +0100 Subject: [PATCH] Avoid fatal errors if folder type information is missing (#1321) --- plugins/libkolab/lib/kolab_storage_cache.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index b16bed93..8c386145 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -29,7 +29,7 @@ class kolab_storage_cache protected $folder; protected $uid2msg; protected $objects; - protected $index = array(); + protected $index = null; protected $metadata = array(); protected $folder_id; protected $resource_uri; @@ -58,8 +58,10 @@ class kolab_storage_cache rcube::raise_error(array( 'code' => 900, 'type' => 'php', - 'message' => "No kolab_storage_cache class found for folder of type " . $storage_folder->type + 'message' => "No kolab_storage_cache class found for folder '$storage_folder->name' of type '$storage_folder->type'" ), true); + + return new kolab_storage_cache($storage_folder); } } @@ -104,7 +106,7 @@ class kolab_storage_cache $this->resource_uri = $this->folder->get_resource_uri(); $this->folders_table = $this->db->table_name('kolab_folders'); $this->cache_table = $this->db->table_name('kolab_cache_' . $this->folder->type); - $this->ready = $this->enabled; + $this->ready = $this->enabled && !empty($this->folder->type); $this->folder_id = null; } @@ -446,7 +448,7 @@ class kolab_storage_cache $filter = $this->_query2assoc($query); // use 'list' for folder's default objects - if ($filter['type'] == $this->type) { + if (is_array($this->index) && $filter['type'] == $this->type) { $index = $this->index; } else { // search by object type @@ -454,10 +456,6 @@ class kolab_storage_cache $index = $this->imap->search_once($this->folder->name, $search)->get(); } - if ($index->is_error()) { - return null; - } - // fetch all messages in $index from IMAP $result = $uids ? $this->_fetch_uids($index, $filter['type']) : $this->_fetch($index, $filter['type']);