[dev] [PATCH] Stale folder lists

Bernard Blackham b-horde at blackham.com.au
Fri Oct 31 08:59:58 PST 2003


Due to some obscure bugs in the caching code in flistSelect() in
lib/IMP.php, folder lists didn't always get updated. Then it was
realised that the caching code wasn't even necessary, as caching is
already done at the folder level, so rebuilding the HTML-list from
it isn't that expensive. So this here just removes all of the
unnecessary caching code and fixes bugs in the process. :)

Regards,

Bernard.

Index: imp/lib/IMP.php
===================================================================
RCS file: /repository/imp/lib/IMP.php,v
retrieving revision 1.401
diff -u -r1.401 IMP.php
--- imp/lib/IMP.php	28 Oct 2003 18:33:38 -0000	1.401
+++ imp/lib/IMP.php	31 Oct 2003 16:49:04 -0000
@@ -453,50 +453,11 @@
     function flistSelect($heading = '', $abbrev = true, $filter = array(),
                          $selected = null, $new_folder_header = false)
     {
-        global $conf, $imp;
-        static $cache;
-
-        $signature = serialize(array($heading, $abbrev, $filter, $selected, $new_folder_header));
-
-        /* Use the cached value, if possible. */
-        if ($conf['server']['cache_folders']) {
-            require_once HORDE_BASE . '/lib/SessionObjects.php';
-            $sessionOb = &Horde_SessionObjects::singleton();
-            if (!isset($imp['cache']['flistselect'])) {
-                $imp['cache']['flistselect'] = array();
-            }
-            $flist_cache = &$imp['cache']['flistselect'];
-            if (isset($imp['cache']['folder_cache']) &&
-                isset($flist_cache['_md5']) &&
-                isset($flist_cache[$signature])) {
-                $md5sum = md5(serialize($imp['cache']['folder_cache']));
-                /* Determine if the folder cache has changed since we last
-                   generated the select list. */
-                if ($md5sum == $flist_cache['_md5']) {
-                    $cachedata = $sessionOb->query($flist_cache[$signature]);
-                    if ($cachedata) {
-                        return $cachedata;
-                    }
-                } else {
-                    unset($flist_cache['_md5']);
-                    foreach ($flist_cache as $key => $val) {
-                        $sessionOb->setPruneFlag($val, true);
-                    }
-                    $flist_cache = array();
-                }
-            }
-        } elseif (isset($cache)) {
-            if (isset($cache[$signature])) {
-                return $cache[$signature];
-            }
-        } else {
-            $cache = array();
-        }
-            
         require_once HORDE_BASE . '/lib/Text.php';
         require_once IMP_BASE . '/lib/Folder.php';
 
         $imp_folder = &IMP_Folder::singleton();
+        /* Caching is performed by flist, so we needed worry about it here. */
         $mailboxes = $imp_folder->flist_IMP($filter);
         $text = '';
 
@@ -519,17 +480,6 @@
                 $label = $mbox['label'];
             }
             $text .= sprintf('<option value="%s"%s>%s</option>%s', $val, $sel, Text::htmlSpaces($label), "\n");
-        }
-
-        /* Cache results. */
-        if ($conf['server']['cache_folders']) {
-            if (!isset($md5sum)) {
-                $md5sum = md5(serialize($imp['cache']['folder_cache']));
-            }
-            $flist_cache['_md5'] = $md5sum;
-            $flist_cache[$signature] = $sessionOb->storeOid($text, false);
-        } else {
-            $cache[$signature] = $text;
         }
 
         return $text;

-- 
 Bernard Blackham 
 bernard at blackham dot com dot au


More information about the dev mailing list