summaryrefslogtreecommitdiff
path: root/roundcubemail
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-07-27 15:53:48 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-07-27 15:53:48 +0000
commitf335d8b8fbe4ac5af3a3ec86176992e89f0045fc (patch)
tree2aad0dde8dc6b412b8a52f2f5e5f856005d340d0 /roundcubemail
parente3bbdb9be2a0631c6c44e74a4dd7a91c582440d2 (diff)
- Delay imap cache initialization, fixes problem with cache cleanup on login (where user ID wasn't set on init time)
git-svn-id: https://svn.roundcube.net/trunk@4978 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail')
-rw-r--r--roundcubemail/program/include/rcube_imap.php29
1 files changed, 21 insertions, 8 deletions
diff --git a/roundcubemail/program/include/rcube_imap.php b/roundcubemail/program/include/rcube_imap.php
index 710a434f2..cfea18928 100644
--- a/roundcubemail/program/include/rcube_imap.php
+++ b/roundcubemail/program/include/rcube_imap.php
@@ -80,6 +80,7 @@ class rcube_imap
private $db_header_fields = array('idx', 'uid', 'subject', 'from', 'to', 'cc', 'date', 'size');
private $options = array('auth_method' => 'check');
private $host, $user, $pass, $port, $ssl;
+ private $caching = false;
/**
* All (additional) headers used (in any way) by Roundcube
@@ -3814,16 +3815,28 @@ class rcube_imap
function set_caching($type)
{
if ($type) {
- $rcmail = rcmail::get_instance();
- $this->cache = $rcmail->get_cache('IMAP', $type);
+ $this->caching = true;
}
else {
if ($this->cache)
$this->cache->close();
$this->cache = null;
+ $this->caching = false;
}
}
+ /**
+ * Getter for IMAP cache object
+ */
+ private function get_cache_engine()
+ {
+ if ($this->caching && !$this->cache) {
+ $rcmail = rcmail::get_instance();
+ $this->cache = $rcmail->get_cache('IMAP', $type);
+ }
+
+ return $this->cache;
+ }
/**
* Returns cached value
@@ -3834,8 +3847,8 @@ class rcube_imap
*/
function get_cache($key)
{
- if ($this->cache) {
- return $this->cache->get($key);
+ if ($cache = $this->get_cache_engine()) {
+ return $cache->get($key);
}
}
@@ -3848,8 +3861,8 @@ class rcube_imap
*/
function update_cache($key, $data)
{
- if ($this->cache) {
- $this->cache->set($key, $data);
+ if ($cache = $this->get_cache_engine()) {
+ $cache->set($key, $data);
}
}
@@ -3863,8 +3876,8 @@ class rcube_imap
*/
function clear_cache($key=null, $prefix_mode=false)
{
- if ($this->cache) {
- $this->cache->remove($key, $prefix_mode);
+ if ($cache = $this->get_cache_engine()) {
+ $cache->remove($key, $prefix_mode);
}
}