Use Horde_Session storage instead of Horde_Cache_Session
authorMichael M Slusarz <slusarz@curecanti.org>
Sun, 10 Oct 2010 19:42:33 +0000 (13:42 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 12 Oct 2010 20:31:23 +0000 (14:31 -0600)
framework/Core/lib/Horde/Core/Factory/Cache.php
framework/Core/lib/Horde/Registry.php
imp/lib/Injector/Factory/Imaptree.php

index 7539fc3..28352df 100644 (file)
@@ -42,25 +42,6 @@ class Horde_Core_Factory_Cache
             $driver = 'Null';
         }
 
-        return $this->_create($driver, $injector);
-    }
-
-    /**
-     * Return the Horde_Cache_Session:: instance.
-     *
-     * @return Horde_Cache_Session
-     * @throws Horde_Cache_Exception
-     */
-    public function createSession(Horde_Injector $injector)
-    {
-        return $this->_create('Session', $injector);
-    }
-
-    /**
-     * @see create()
-     */
-    private function _create($driver, $injector)
-    {
         $params = Horde::getDriverConfig('cache', $driver);
         if (isset($GLOBALS['conf']['cache']['default_lifetime'])) {
             $params['lifetime'] = $GLOBALS['conf']['cache']['default_lifetime'];
index 644c89d..7f13950 100644 (file)
@@ -255,10 +255,6 @@ class Horde_Registry
             'Horde_Alarm' => 'Horde_Core_Factory_Alarm',
             'Horde_Browser' => 'Horde_Core_Factory_Browser',
             'Horde_Cache' => 'Horde_Core_Factory_Cache',
-            'Horde_Cache_Session' => array(
-                'Horde_Core_Factory_Cache',
-                'createSession',
-            ),
             'Horde_Controller_Request' => 'Horde_Core_Factory_Request',
             'Horde_Controller_RequestConfiguration' => array(
                 'Horde_Core_Controller_RequestMapper',
index e4f6bfb..706ffeb 100644 (file)
@@ -40,22 +40,22 @@ class IMP_Injector_Factory_Imaptree
 
         /* If an IMP_Imap_Tree object is currently stored in the cache,
          * re-create that object.  Else, create a new instance. */
-        if (isset($session['imp:tree'])) {
+        if (isset($session['imp:treeob'])) {
             /* Since IMAP tree generation is so expensive/time-consuming,
              * fallback to storing in the session even if no permanent cache
              * backend is setup. */
             $cache = $injector->getInstance('Horde_Cache');
             if ($cache instanceof Horde_Cache_Null) {
-                $cache = $injector->getInstance('Horde_Cache_Session');
-            }
-
-            try {
-                $instance = @unserialize($cache->get($session['imp:tree'], 86400));
-            } catch (Exception $e) {
-                Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
+                $instance = $session[Horde_Session::DATA . ':imp_imaptree'];
+            } else {
+                try {
+                    $instance = @unserialize($cache->get($session['imp:treeob'], 86400));
+                } catch (Exception $e) {
+                    Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
+                }
             }
         } else {
-            $session['imp:tree'] = strval(new Horde_Support_Randomid());
+            $session['imp:treeob'] = strval(new Horde_Support_Randomid());
         }
 
         if (!($instance instanceof IMP_Imap_Tree)) {
@@ -75,13 +75,16 @@ class IMP_Injector_Factory_Imaptree
      */
     public function shutdown($instance, $injector)
     {
+        global $session;
+
         /* Only need to store the object if the tree has changed. */
         if ($instance->changed) {
             $cache = $injector->getInstance('Horde_Cache');
             if ($cache instanceof Horde_Cache_Null) {
-                $cache = $injector->getInstance('Horde_Cache_Session');
+                $session->store($instance, true, 'imp_imaptree');
+            } else {
+                $cache->set($GLOBALS['session']['imp:treeob'], serialize($instance), 86400);
             }
-            $cache->set($GLOBALS['session']['imp:tree'], serialize($instance), 86400);
         }
     }