diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index e8e69318..7c8575e5 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -761,17 +761,17 @@ class kolab_storage_cache * Select Kolab objects filtered by the given query * * @param array Pseudo-SQL query as list of filter parameter triplets - * triplet: array('', '', '') - * @param boolean Set true to only return UIDs instead of complete objects - * @param boolean Use fast mode to fetch only minimal set of information - * (no xml fetching and parsing, etc.) + * triplet: array('', '', '') + * @param bool Set true to only return UIDs instead of complete objects + * @param bool Use fast mode to fetch only minimal set of information + * (no xml fetching and parsing, etc.) * - * @return array List of Kolab data objects (each represented as hash array) or UIDs + * @return null|array|kolab_storage_dataset List of Kolab data objects + * (each represented as hash array) or UIDs */ public function select($query = array(), $uids = false, $fast = false) { $result = $uids ? array() : new kolab_storage_dataset($this); - $count = null; // read from local cache DB (assume it to be synchronized) if ($this->ready) { @@ -780,11 +780,6 @@ class kolab_storage_cache // fetch full object data unless only uids are requested $fetchall = !$uids; - // skip SELECT if we know it will return nothing - if ($count === 0) { - return $result; - } - $sql_query = "SELECT " . ($fetchall ? '*' : "`msguid` AS `_msguid`, `uid`") . " FROM `{$this->cache_table}` WHERE `folder_id` = ?" . $this->_sql_where($query) diff --git a/plugins/libkolab/lib/kolab_storage_config.php b/plugins/libkolab/lib/kolab_storage_config.php index 76ffaf30..9168c2c2 100644 --- a/plugins/libkolab/lib/kolab_storage_config.php +++ b/plugins/libkolab/lib/kolab_storage_config.php @@ -26,7 +26,7 @@ class kolab_storage_config { const FOLDER_TYPE = 'configuration'; - const MAX_RELATIONS = 499; // should be less than kolab_storage_cache::MAX_RECORDS + const MAX_RELATIONS = 499; /** * Singleton instace of kolab_storage_config diff --git a/plugins/libkolab/lib/kolab_storage_dav_cache.php b/plugins/libkolab/lib/kolab_storage_dav_cache.php index 2bc4b317..12244cec 100644 --- a/plugins/libkolab/lib/kolab_storage_dav_cache.php +++ b/plugins/libkolab/lib/kolab_storage_dav_cache.php @@ -414,19 +414,10 @@ class kolab_storage_dav_cache extends kolab_storage_cache public function select($query = [], $uids = false, $fast = false) { $result = $uids ? [] : new kolab_storage_dataset($this); - $count = null; $this->_read_folder_data(); - // fetch full object data on one query if a small result set is expected - $fetchall = !$uids && ($this->limit ? $this->limit[0] : ($count = $this->count($query))) < self::MAX_RECORDS; - - // skip SELECT if we know it will return nothing - if ($count === 0) { - return $result; - } - - $sql_query = "SELECT " . ($fetchall ? '*' : "`uid`") + $sql_query = "SELECT " . ($uids ? "`uid`" : '*') . " FROM `{$this->cache_table}` WHERE `folder_id` = ?" . $this->_sql_where($query) . (!empty($this->order_by) ? " ORDER BY " . $this->order_by : ''); @@ -445,13 +436,7 @@ class kolab_storage_dav_cache extends kolab_storage_cache } while ($sql_arr = $this->db->fetch_assoc($sql_result)) { - if ($uids) { - $result[] = $sql_arr['uid']; - } - else if (!$fetchall) { - $result[] = $sql_arr; - } - else if (($object = $this->_unserialize($sql_arr, true, $fast))) { + if (!$uids && ($object = $this->_unserialize($sql_arr, true, $fast))) { $result[] = $object; } else {