From 0131c8aa513cbea8ae78abca654c18ddd0499b70 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Wed, 9 May 2012 19:12:26 +0200 Subject: [PATCH] Improve object fetching when cache is disabled --- plugins/libkolab/lib/kolab_storage_cache.php | 13 +++++++++- plugins/libkolab/lib/kolab_storage_folder.php | 26 ------------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index 65aa4cb7..9f9431c6 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -301,7 +301,18 @@ class kolab_storage_cache else { // extract object type from query parameter $filter = $this->_query2assoc($query); - $result = $this->_fetch($this->index, $filter['type']); + + // use 'list' for folder's default objects + if ($filter['type'] == $this->type) { + $index = $this->index; + } + else { // search by object type + $search = 'UNDELETED HEADER X-Kolab-Type ' . kolab_storage_folder::KTYPE_PREFIX . $filter['type']; + $index = $this->imap->search_once($this->folder->name, $search)->get(); + } + + // fetch all messages in $index from IMAP + $result = $this->_fetch($index, $filter['type']); // TODO: post-filter result according to query } diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php index eed7b08a..d6919064 100644 --- a/plugins/libkolab/lib/kolab_storage_folder.php +++ b/plugins/libkolab/lib/kolab_storage_folder.php @@ -288,32 +288,6 @@ class kolab_storage_folder // fetch objects from cache return $this->cache->select(array(array('type','=',$type))); - -/* - $results = array(); - $ctype = self::KTYPE_PREFIX . $type; - - // use 'list' for folder's default objects - if ($type == $this->type) { - $index = $this->imap->index($this->name); - } - else { // search by object type - $search = 'UNDELETED HEADER X-Kolab-Type ' . $ctype; - $index = $this->imap->search_once($this->name, $search); - } - - // fetch all messages from IMAP - foreach ($index->get() as $msguid) { - if ($object = $this->read_object($msguid, $type)) { - $results[] = $object; - $this->uid2msg[$object['uid']] = $msguid; - } - } - - // TODO: write $this->uid2msg to cache - - return $results; -*/ }