summaryrefslogtreecommitdiff
path: root/plugins/libkolab/lib/kolab_storage_config.php
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-10-13 16:12:59 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-10-13 16:12:59 (GMT)
commitf505abb3506c9f2e413e2c625387b53167f7ac79 (patch)
treecb564a5c664e0612dda9abc04b6e27fe959018b1 /plugins/libkolab/lib/kolab_storage_config.php
parent80f23d7d9074b57f879fb4077db648a7a5b3666f (diff)
downloadroundcubemail-plugins-kolab-f505abb3506c9f2e413e2c625387b53167f7ac79.tar.gz
Keep kolab uids related to a message in memory for repeated queries
Diffstat (limited to 'plugins/libkolab/lib/kolab_storage_config.php')
-rw-r--r--plugins/libkolab/lib/kolab_storage_config.php38
1 files changed, 24 insertions, 14 deletions
diff --git a/plugins/libkolab/lib/kolab_storage_config.php b/plugins/libkolab/lib/kolab_storage_config.php
index 293d524..d58e3c0 100644
--- a/plugins/libkolab/lib/kolab_storage_config.php
+++ b/plugins/libkolab/lib/kolab_storage_config.php
@@ -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,24 +779,32 @@ class kolab_storage_config
}
$filter[] = array('member', '=', $member_id);
- // get UIDs of assigned notes
- 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'])) {
- // update members...
- $messages = kolab_storage_config::resolve_members($relation);
- // ...and check again
- if (empty($messages[$folder]) || !in_array($message->uid, $messages[$folder])) {
- continue;
+ 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'])) {
+ // update members...
+ $messages = kolab_storage_config::resolve_members($relation);
+ // ...and check again
+ if (empty($messages[$folder]) || !in_array($message->uid, $messages[$folder])) {
+ continue;
+ }
}
- }
- // find groupware object UID(s)
- foreach ($relation['members'] as $member) {
- if (strpos($member, 'urn:uuid:') === 0) {
- $uids[] = substr($member, 9);
+ // find groupware object UID(s)
+ foreach ($relation['members'] as $member) {
+ if (strpos($member, 'urn:uuid:') === 0) {
+ $uids[] = substr($member, 9);
+ }
}
}
+
+ // remember this lookup
+ $_cache[$uri] = $uids;
+ }
+ else {
+ $uids = $_cache[$uri];
}
// get kolab objects of specified type