summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap.php
diff options
context:
space:
mode:
Diffstat (limited to 'program/include/rcube_imap.php')
-rw-r--r--program/include/rcube_imap.php38
1 files changed, 28 insertions, 10 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index f401f3707..b966aa348 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -3424,7 +3424,7 @@ class rcube_imap extends rcube_storage
return false;
}
- $this->clear_cache('mailboxes.metadata.' . $folder);
+ $this->clear_cache('mailboxes.metadata.', true);
if ($this->get_capability('METADATA') ||
(!strlen($folder) && $this->get_capability('METADATA-SERVER'))
@@ -3458,9 +3458,9 @@ class rcube_imap extends rcube_storage
return false;
}
- $this->clear_cache('mailboxes.metadata.' . $folder);
+ $this->clear_cache('mailboxes.metadata.', true);
- if ($this->get_capability('METADATA') ||
+ if ($this->get_capability('METADATA') ||
(!strlen($folder) && $this->get_capability('METADATA-SERVER'))
) {
return $this->conn->deleteMetadata($folder, $entries);
@@ -3489,27 +3489,38 @@ class rcube_imap extends rcube_storage
*/
public function get_metadata($folder, $entries, $options=array())
{
+ $entries = (array)$entries;
+
+ // create cache key
+ // @TODO: this is the simplest solution, but we do the same with folders list
+ // maybe we should store data per-entry and merge on request
+ sort($options);
+ sort($entries);
+ $cache_key = 'mailboxes.metadata.' . $folder;
+ $cache_key .= '.' . md5(serialize($options).serialize($entries));
+
+ // get cached data
+ $cached_data = $this->get_cache($cache_key);
+
+ if (is_array($cached_data)) {
+ return $cached_data;
+ }
+
if (!$this->check_connection()) {
return null;
}
- $cache_key = 'mailboxes.metadata.' . $folder;
- if ($cached = $this->get_cache($cache_key))
- return $cached;
-
if ($this->get_capability('METADATA') ||
(!strlen($folder) && $this->get_capability('METADATA-SERVER'))
) {
$res = $this->conn->getMetadata($folder, $entries, $options);
- $this->update_cache($cache_key, $res);
- return $res;
}
else if ($this->get_capability('ANNOTATEMORE') || $this->get_capability('ANNOTATEMORE2')) {
$queries = array();
$res = array();
// Convert entry names
- foreach ((array)$entries as $entry) {
+ foreach ($entries as $entry) {
list($ent, $attr) = $this->md2annotate($entry);
$queries[$attr][] = $ent;
}
@@ -3520,7 +3531,9 @@ class rcube_imap extends rcube_storage
$res = array_merge_recursive($res, $result);
}
}
+ }
+ if (isset($res)) {
$this->update_cache($cache_key, $res);
return $res;
}
@@ -3955,6 +3968,11 @@ class rcube_imap extends rcube_storage
return $this->list_messages($folder, $page, $sort_field, $sort_order, $slice);
}
+ public function get_headers($uid, $folder = null, $force = false)
+ {
+ return $this->get_message_headers($uid, $folder, $force);
+ }
+
public function mailbox_status($folder = null)
{
return $this->folder_status($folder);