Keep kolab uids related to a message in memory for repeated queries

This commit is contained in:
Thomas Bruederli 2014-10-13 18:12:59 +02:00
parent 80f23d7d90
commit f505abb350

View file

@ -760,6 +760,8 @@ class kolab_storage_config
*/
public function get_message_relations($message, $folder, $type)
{
static $_cache = array();
$result = array();
$uids = array();
$default = true;
@ -777,7 +779,8 @@ class kolab_storage_config
}
$filter[] = array('member', '=', $member_id);
// get UIDs of assigned notes
if (!isset($_cache[$uri])) {
// get UIDs of related groupware objects
foreach ($this->get_objects($filter, $default) as $relation) {
// we don't need to update members if the URI is found
if (!in_array($uri, $relation['members'])) {
@ -797,6 +800,13 @@ class kolab_storage_config
}
}
// remember this lookup
$_cache[$uri] = $uids;
}
else {
$uids = $_cache[$uri];
}
// get kolab objects of specified type
if (!empty($uids)) {
$query = array(array('uid', '=', array_unique($uids)));