From 61134c2954711716d52cef97d9f5fea32cfbec93 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 24 Aug 2010 01:38:54 -0600 Subject: [PATCH] Remove folder list caching. Folder lists are cached in the IMP_Imap_Tree object. No need to cache this information multiple times. --- imp/config/conf.xml | 7 ---- imp/docs/UPGRADING | 3 +- imp/folders.php | 1 - imp/lib/Ajax/Application.php | 1 - imp/lib/Application.php | 2 - imp/lib/Folder.php | 80 -------------------------------------- imp/lib/Injector/Binder/Folder.php | 35 ----------------- 7 files changed, 2 insertions(+), 127 deletions(-) delete mode 100644 imp/lib/Injector/Binder/Folder.php diff --git a/imp/config/conf.xml b/imp/config/conf.xml index bd6ecf90e..0d342c2f4 100644 --- a/imp/config/conf.xml +++ b/imp/config/conf.xml @@ -61,13 +61,6 @@ list of folders that can't be modified (deleted, renamed, etc) by the user, e.g.: "Drafts, Trash". (The mailbox value must be encoded in the UTF7-IMAP charset; see RFC 3501 [5.1.3])"/> - true diff --git a/imp/docs/UPGRADING b/imp/docs/UPGRADING index c17e39b6c..869dac482 100644 --- a/imp/docs/UPGRADING +++ b/imp/docs/UPGRADING @@ -53,7 +53,8 @@ hook. The 'max_from_chars' and 'max_subj_chars' configuration options for the minimal (mimp) display have been removed. -The 'limit_factor' and 'sort_limit' configuration options have been removed. +The 'cache_folders', 'limit_factor', and 'sort_limit' configuration options +have been removed. Preferences diff --git a/imp/folders.php b/imp/folders.php index 6465774e8..6364f60e3 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -82,7 +82,6 @@ case 'collapse_all_folders': break; case 'rebuild_tree': - $imp_folder->clearFlistCache(); $imaptree->init(); break; diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 714e44dd3..88e8407b5 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -305,7 +305,6 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application } if ($this->_vars->reload) { - $GLOBALS['injector']->getInstance('IMP_Folder')->clearFlistCache(); $imptree->init(); } diff --git a/imp/lib/Application.php b/imp/lib/Application.php index ef1f7e481..0c68b5831 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -95,7 +95,6 @@ class IMP_Application extends Horde_Registry_Application 'IMP_Contents' => new IMP_Injector_Binder_Contents(), 'IMP_Crypt_Pgp' => new IMP_Injector_Binder_Pgp(), 'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(), - 'IMP_Folder' => new IMP_Injector_Binder_Folder(), 'IMP_Identity' => new IMP_Injector_Binder_Identity(), 'IMP_Imap' => new IMP_Injector_Binder_Imap(), 'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(), @@ -464,7 +463,6 @@ class IMP_Application extends Horde_Registry_Application */ public function mailboxesChanged() { - $GLOBALS['injector']->getInstance('IMP_Folder')->clearFlistCache(); $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->init(); } diff --git a/imp/lib/Folder.php b/imp/lib/Folder.php index c4884e925..5e4d525b6 100644 --- a/imp/lib/Folder.php +++ b/imp/lib/Folder.php @@ -32,32 +32,6 @@ class IMP_Folder ); /** - * Keep around identical lists so that we don't hit the server more that - * once in the same page for the same thing. - * - * @var array - */ - protected $_listCache = null; - - /** - * The cache ID used to store mailbox info. - * - * @var string - */ - protected $_cacheid = null; - - /** - * Constructor. - * - * @param string $cacheid The cache ID to use, if folder list caching is - * enabled. - */ - public function __construct($cacheid = null) - { - $this->_cacheid = $cacheid; - } - - /** * Lists folders. * * @param array $filter An list of mailboxes that should be left out of @@ -90,29 +64,6 @@ class IMP_Folder $sub = $GLOBALS['prefs']->getValue('subscribe'); } - /* Compute values that will uniquely identify this list. */ - $sig = hash('md5', serialize(array(intval($sub), $filter))); - - /* Either get the list from the cache, or go to the IMAP server to - obtain it. */ - $cache = null; - if (is_null($this->_listCache)) { - if (!is_null($this->_cacheid) && ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) { - $ret = $cache->get($this->_cacheid, 3600); - if (!empty($ret)) { - $this->_listCache = unserialize($ret); - } - } - - if (empty($this->_listCache)) { - $this->_listCache = array(); - } - } - - if (isset($this->_listCache[$sig])) { - return $this->_listCache[$sig]; - } - $imaptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree'); $list_mask = IMP_Imap_Tree::FLIST_CONTAINER; if (!$sub) { @@ -138,29 +89,10 @@ class IMP_Folder $list = $inbox_entry + $list; } - $this->_listCache[$sig] = $list; - - /* Save in cache, if needed. */ - if (!is_null($cache)) { - $cache->set($this->_cacheid, serialize($this->_listCache), 3600); - } - return $list; } /** - * Clears the flist folder cache. - */ - public function clearFlistCache() - { - if (!is_null($this->_cacheid) && - ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) { - $cache->expire($this->_cacheid); - } - $this->_listCache = array(); - } - - /** * Deletes one or more folders. * * @param array $folders Folders to be deleted (UTF7-IMAP). @@ -207,9 +139,6 @@ class IMP_Folder */ protected function _onDelete($deleted) { - /* Reset the folder cache. */ - $this->clearFlistCache(); - /* Recreate Virtual Folders. */ $GLOBALS['injector']->getInstance('IMP_Search')->initialize(true); @@ -292,9 +221,6 @@ class IMP_Folder $this->subscribe(array($folder)); } - /* Reset the folder cache. */ - $this->clearFlistCache(); - /* Update the mailbox tree. */ $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->insert($folder); @@ -415,9 +341,6 @@ class IMP_Folder if (!empty($subscribed)) { $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->subscribe($subscribed); - - /* Reset the folder cache. */ - $this->clearFlistCache(); } return $return_value; @@ -459,9 +382,6 @@ class IMP_Folder if (!empty($unsubscribed)) { $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->unsubscribe($unsubscribed); - - /* Reset the folder cache. */ - $this->clearFlistCache(); } return $return_value; diff --git a/imp/lib/Injector/Binder/Folder.php b/imp/lib/Injector/Binder/Folder.php deleted file mode 100644 index 4820d148e..000000000 --- a/imp/lib/Injector/Binder/Folder.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @category Horde - * @license http://www.fsf.org/copyleft/gpl.html GPL - * @package IMP - */ -class IMP_Injector_Binder_Folder implements Horde_Injector_Binder -{ - /** - */ - public function create(Horde_Injector $injector) - { - $cacheid = empty($GLOBALS['conf']['server']['cache_folders']) - ? null - : 'imp_folder_cache|' . $GLOBALS['registry']->getAuth() . '|' . $_SESSION['imp']['server_key']; - - return new IMP_Folder($cacheid); - } - - /** - */ - public function equals(Horde_Injector_Binder $binder) - { - return false; - } - -} -- 2.11.0