diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -646,28 +646,35 @@ else { $filter = $this->_query2assoc($query); - $this->imap_mode(true); + if ($filter['uid']) { + // We already know what we want (Maybe we will not know if we switch this around to using event uids) + $index = [$filter['uid']]; + } else { + // Search for what we want + $this->imap_mode(true); - if ($filter['type']) { - $search = 'UNDELETED HEADER X-Kolab-Type ' . kolab_format::KTYPE_PREFIX . $filter['type']; - $index = $this->imap->search_once($this->folder->name, $search); - } - else { - $index = $this->imap->index($this->folder->name, null, null, true, true); - } + if ($filter['type']) { + $search = 'UNDELETED HEADER X-Kolab-Type ' . kolab_format::KTYPE_PREFIX . $filter['type']; + $index = $this->imap->search_once($this->folder->name, $search); + } + else { + $index = $this->imap->index($this->folder->name, null, null, true, true); + } - $this->imap_mode(false); + $this->imap_mode(false); - if ($index->is_error()) { - $this->check_error(); - if ($uids) { - return null; + if ($index->is_error()) { + $this->check_error(); + if ($uids) { + return null; + } + $result->set_error(true); + return $result; } - $result->set_error(true); - return $result; - } - $index = $index->get(); + // Results come in the wrong order by default + $index = array_reverse($index->get()); + } $result = $uids ? $index : $this->_fetch($index, $filter['type']); // TODO: post-filter result according to query