From 341d9661c7b10ebf5e888d1a7eeb838bab59f7de Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 27 Jul 2011 11:53:48 -0400
Subject: [PATCH] - Delay imap cache initialization, fixes problem with cache cleanup on login (where user ID wasn't set on init time)
---
program/include/rcube_imap.php | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 710a434..cfea189 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -80,6 +80,7 @@
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 @@
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 @@
*/
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 @@
*/
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 @@
*/
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);
}
}
--
Gitblit v1.9.1