diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index d56f04d5..eec058d8 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -265,8 +265,10 @@ class kolab_storage_cache // fetch from IMAP if not present in cache if (empty($this->objects[$msguid])) { - $result = $this->_fetch(array($msguid), $type, $foldername); - $this->objects = array($msguid => $result[0]); // store only this object in memory (#2827) + if ($object = $this->folder->read_object($msguid, $type ?: '*', $foldername)) { + $this->objects = array($msguid => $object); + $this->set($msguid, $object); + } } } diff --git a/plugins/libkolab/lib/kolab_storage_cache_configuration.php b/plugins/libkolab/lib/kolab_storage_cache_configuration.php index ec015dd7..c3c7ac4f 100644 --- a/plugins/libkolab/lib/kolab_storage_cache_configuration.php +++ b/plugins/libkolab/lib/kolab_storage_cache_configuration.php @@ -38,6 +38,28 @@ class kolab_storage_cache_configuration extends kolab_storage_cache return $sql_data; } + /** + * Select Kolab objects filtered by the given query + * + * @param array Pseudo-SQL query as list of filter parameter triplets + * @param boolean Set true to only return UIDs instead of complete objects + * @return array List of Kolab data objects (each represented as hash array) or UIDs + */ + public function select($query = array(), $uids = false) + { + // modify query for IMAP search: query param 'type' is actually a subtype + if (!$this->ready) { + foreach ($query as $i => $tuple) { + if ($tuple[0] == 'type') { + $tuple[2] = 'configuration.' . $tuple[2]; + $query[$i] = $tuple; + } + } + } + + return parent::select($query, $uids); + } + /** * Helper method to compose a valid SQL query from pseudo filter triplets */ diff --git a/plugins/libkolab/lib/kolab_storage_config.php b/plugins/libkolab/lib/kolab_storage_config.php index 9bc5d509..8a0fab5c 100644 --- a/plugins/libkolab/lib/kolab_storage_config.php +++ b/plugins/libkolab/lib/kolab_storage_config.php @@ -125,6 +125,7 @@ class kolab_storage_config } foreach ($folder->select($filter) as $object) { + unset($object['_formatobj']); $list[] = $object; } } @@ -626,20 +627,24 @@ class kolab_storage_config // use faster method if ($uid && $uid != '*') { $filter[] = array('member', '=', $uid); - return $this->get_objects($filter, $default); + $tags = $this->get_objects($filter, $default); } - - $this->tags = $this->get_objects($filter, $default); + else { + $this->tags = $tags = $this->get_objects($filter, $default); + } + } + else { + $tags = $this->tags; } if ($uid === '*') { - return $this->tags; + return $tags; } $result = array(); $search = self::build_member_url($uid); - foreach ($this->tags as $tag) { + foreach ($tags as $tag) { if (in_array($search, (array) $tag['members'])) { $result[] = $tag; }