Remove folder list caching.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 24 Aug 2010 07:38:54 +0000 (01:38 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 24 Aug 2010 07:40:08 +0000 (01:40 -0600)
Folder lists are cached in the IMP_Imap_Tree object. No need to cache
this information multiple times.

imp/config/conf.xml
imp/docs/UPGRADING
imp/folders.php
imp/lib/Ajax/Application.php
imp/lib/Application.php
imp/lib/Folder.php
imp/lib/Injector/Binder/Folder.php [deleted file]

index bd6ecf9..0d342c2 100644 (file)
    list of folders that can't be modified (deleted, renamed, etc) by the user,
    e.g.: &quot;Drafts, Trash&quot;. (The mailbox value must be encoded in the
    UTF7-IMAP charset; see RFC 3501 [5.1.3])"/>
-   <configboolean name="cache_folders" desc="If using IMAP, should we cache the
-   list of folders so that the list does not need to be rebuilt on every page
-   load? If set to true, note that any folders created on the server during an
-   IMP session that are NOT created via IMP will not be displayed until the
-   next login. If IMP will be the exclusive means of accessing the mail server,
-   or you are not concerned about this behavior, this setting should be set to
-   true.">true</configboolean>
   </configsection>
  </configtab>
 
index c17e39b..869dac4 100644 (file)
@@ -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
index 6465774..6364f60 100644 (file)
@@ -82,7 +82,6 @@ case 'collapse_all_folders':
     break;
 
 case 'rebuild_tree':
-    $imp_folder->clearFlistCache();
     $imaptree->init();
     break;
 
index 714e44d..88e8407 100644 (file)
@@ -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();
         }
 
index ef1f7e4..0c68b58 100644 (file)
@@ -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();
     }
 
index c4884e9..5e4d525 100644 (file)
@@ -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 (file)
index 4820d14..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Binder for IMP_Folder::.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @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;
-    }
-
-}