Performance: Optimize get_message_relations() to use one query per-folder less
Fix bug where in kolab_storage::select() could not initialize/reset folder cache properly
This commit is contained in:
parent
11ce37ef17
commit
9972823957
2 changed files with 9 additions and 6 deletions
|
@ -233,20 +233,23 @@ class kolab_storage
|
|||
*
|
||||
* @param array Pseudo-SQL query as list of filter parameter triplets
|
||||
* @param string Object type (contact,event,task,journal,file,note,configuration)
|
||||
* @param int Expected number of records or limit (for performance reasons)
|
||||
*
|
||||
* @return array List of Kolab data objects (each represented as hash array)
|
||||
* @see kolab_storage_format::select()
|
||||
*/
|
||||
public static function select($query, $type)
|
||||
public static function select($query, $type, $limit = null)
|
||||
{
|
||||
self::setup();
|
||||
$folder = null;
|
||||
$result = array();
|
||||
|
||||
foreach ((array)self::list_folders('', '*', $type, null, $folderdata) as $foldername) {
|
||||
if (!$folder)
|
||||
$folder = new kolab_storage_folder($foldername, $type, $folderdata[$foldername]);
|
||||
else
|
||||
$folder->set_folder($foldername, $type, $folderdata[$foldername]);
|
||||
$folder = new kolab_storage_folder($foldername, $type, $folderdata[$foldername]);
|
||||
|
||||
if ($limit) {
|
||||
$folder->set_order_and_limit(null, $limit);
|
||||
}
|
||||
|
||||
foreach ($folder->select($query, '*') as $object) {
|
||||
$result[] = $object;
|
||||
|
|
|
@ -930,7 +930,7 @@ class kolab_storage_config
|
|||
// get kolab objects of specified type
|
||||
if (!empty($uids)) {
|
||||
$query = array(array('uid', '=', array_unique($uids)));
|
||||
$result = kolab_storage::select($query, $type);
|
||||
$result = kolab_storage::select($query, $type, count($uids));
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
Loading…
Add table
Reference in a new issue