From 787e597f62bc99063123cb70ee450192db1f5527 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sun, 10 Oct 2010 13:42:33 -0600 Subject: [PATCH] Use Horde_Session storage instead of Horde_Cache_Session --- framework/Core/lib/Horde/Core/Factory/Cache.php | 19 ------------------- framework/Core/lib/Horde/Registry.php | 4 ---- imp/lib/Injector/Factory/Imaptree.php | 25 ++++++++++++++----------- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/framework/Core/lib/Horde/Core/Factory/Cache.php b/framework/Core/lib/Horde/Core/Factory/Cache.php index 7539fc37e..28352df1e 100644 --- a/framework/Core/lib/Horde/Core/Factory/Cache.php +++ b/framework/Core/lib/Horde/Core/Factory/Cache.php @@ -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']; diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index 644c89d78..7f1395082 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -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', diff --git a/imp/lib/Injector/Factory/Imaptree.php b/imp/lib/Injector/Factory/Imaptree.php index e4f6bfbec..706ffeb2e 100644 --- a/imp/lib/Injector/Factory/Imaptree.php +++ b/imp/lib/Injector/Factory/Imaptree.php @@ -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); } } -- 2.11.0