All code should now use injector to get a Horde_Cache instance
authorMichael M Slusarz <slusarz@curecanti.org>
Sun, 31 Jan 2010 00:42:11 +0000 (17:42 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Sun, 31 Jan 2010 04:15:14 +0000 (21:15 -0700)
39 files changed:
agora/lib/Messages.php
agora/rss/index.php
agora/rss/messages.php
agora/rss/threads.php
ansel/lib/Application.php
chora/lib/Application.php
folks/lib/Block/my_comments.php
folks/lib/Friends.php
folks/lib/base.php
framework/Cache/lib/Horde/Cache.php
framework/Cache/lib/Horde/Cache/Sql.php
framework/Core/lib/Horde.php
framework/Core/lib/Horde/Core/Binder/Cache.php
framework/Group/Group/contactlists.php
framework/Imap_Client/lib/Horde/Imap/Client/Cache.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Cache.php
framework/Perms/lib/Horde/Perms/Datatree.php
framework/Perms/lib/Horde/Perms/Permission/DataTreeObject.php
framework/Perms/lib/Horde/Perms/Permission/SqlObject.php
framework/Perms/lib/Horde/Perms/Sql.php
framework/Template/lib/Horde/Template.php
framework/Ui/lib/Horde/Ui/VarRenderer/Html.php
gollem/lib/Gollem.php
horde/lib/Block/feed/reader.php
horde/lib/Block/twitter_timeline.php
horde/services/cache.php
horde/services/cacheview.php
horde/services/twitter.php
hylax/img.php
imp/lib/Crypt/Pgp.php
imp/lib/Folder.php
imp/lib/IMP.php
imp/lib/Imap.php
imp/lib/Imap/Tree.php
news/lib/Block/my_comments.php
news/lib/base.php
operator/lib/Application.php
turba/lib/Driver/Imsp.php

index 0f23255..79f7211 100644 (file)
@@ -89,8 +89,7 @@ class Agora_Messages {
         $this->_connect();
 
         /* Initialize the Cache object. */
-        $this->_cache = &Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                                Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
     }
 
     /**
index 12e47fd..596b74f 100644 (file)
@@ -16,8 +16,7 @@ $scope = Horde_Util::getGet('scope', 'agora');
 $cache_key = 'agora_rss_' . $scope;
 
 /* Initialize the Cache object. */
-$cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+$cache = $injector->getInstance('Horde_Cache')
 
 $rss = $cache->get($cache_key, $conf['cache']['default_lifetime']);
 if (!$rss) {
index bd31ebd..c7932d4 100644 (file)
@@ -16,13 +16,10 @@ list($forum_id, $message_id, $scope) = Agora::getAgoraId();
 $cache_key = 'agora_rss_' . $scope . '_' . $forum_id . '_' . $message_id;
 
 /* Initialize the Cache object. */
-$cache = &Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                    Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
-
+$cache = $injector->getInstance('Horde_Cache');
 $rss = $cache->get($cache_key, $conf['cache']['default_lifetime']);
 
 if (!$rss) {
-
     $messages = Agora_Messages::singleton($scope, $forum_id);
     $message = $messages->getMessage($message_id);
     if ($message instanceof PEAR_Error) {
index bfc3484..ebd99a7 100644 (file)
@@ -34,13 +34,10 @@ if ($scope != 'agora') {
 $cache_key = 'agora_rss_' . $scope . '_' . $forum_id;
 
 /* Initialize the Cache object. */
-$cache = &Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                    Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
-
+$cache = $injector->getInstance('Horde_Cache');
 $rss = $cache->get($cache_key, $conf['cache']['default_lifetime']);
 
 if (!$rss) {
-
     // Get forum title
     $threads = Agora_Messages::singleton($scope, $forum_id);
     if ($threads instanceof PEAR_Error) {
index b8de797..064cf33 100644 (file)
@@ -59,7 +59,7 @@ class Ansel_Application extends Horde_Registry_Application
     {
         // Create a cache object if we need it.
         if ($GLOBALS['conf']['ansel_cache']['usecache']) {
-            $GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+            $GLOBALS['cache'] = $GLOBALS['injector']->getInstance('Horde_Cache');
         }
 
         // Create db, share, and vfs instances.
index 0be528c..3899634 100644 (file)
@@ -123,11 +123,9 @@ class Chora_Application extends Horde_Registry_Application
         $sourceroot = $acts['rt'];
 
         // Cache.
-        if (empty($conf['caching'])) {
-            $cache = null;
-        } else {
-            $cache = Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
-        }
+        $cache = empty($conf['caching'])
+            ? null
+            : $GLOBALS['injector']->getInstance('Horde_Cache');
 
         $conf['paths']['temp'] = Horde::getTempDir();
 
index 581cbfa..b00ff9b 100644 (file)
@@ -40,8 +40,7 @@ class Horde_Block_folks_my_comments extends Horde_Block {
             return '';
         }
 
-        $GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                           Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $GLOBALS['cache'] = $GLOBALS['injector']->getInstance('Horde_Cache');
 
         $cache_key = 'folks_myscommetns_' . $this->_params['limit'];
         $threads = $GLOBALS['cache']->get($cache_key, $GLOBALS['conf']['cache']['default_lifetime']);
index a857a2b..ad0e3a9 100644 (file)
@@ -114,8 +114,7 @@ class Folks_Friends {
     {
         $this->_user = empty($params['user']) ? Horde_Auth::getAuth() : $params['user'];
 
-        $this->_cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                            Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
     }
 
     /**
index ba1cbe3..ae9f7d9 100644 (file)
@@ -38,8 +38,7 @@ if (!defined('FOLKS_BASE')) {
 $GLOBALS['folks_driver'] = Folks_Driver::factory();
 
 // Cache
-$GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                            Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+$GLOBALS['cache'] = $injector->getInstance('Horde_Cache');
 
 // Update user online status
 $GLOBALS['folks_driver']->updateOnlineStatus();
index 2aeb301..ea6bdf9 100644 (file)
 class Horde_Cache
 {
     /**
-     * Singleton instances.
-     *
-     * @var array
-     */
-    static protected $_instances = array();
-
-    /**
      * Attempts to return a concrete Horde_Cache instance based on $driver.
      *
      * @param mixed $driver  The type of concrete Horde_Cache subclass to
@@ -48,10 +41,6 @@ class Horde_Cache
             return new Horde_Cache_Null($params);
         }
 
-        if ($driver == 'memcache') {
-            $params['memcache'] = $GLOBALS['injector']->getInstance('Horde_Memcache');
-        }
-
         $class = (empty($app) ? 'Horde' : $app) . '_Cache_' . ucfirst($driver);
         if (class_exists($class)) {
             return new $class($params);
@@ -60,37 +49,4 @@ class Horde_Cache
         throw new Horde_Exception('Class definition of ' . $class . ' not found.');
     }
 
-    /**
-     * Attempts to return a reference to a concrete Horde_Cache instance
-     * based on $driver. It will only create a new instance if no
-     * Horde_Cache instance with the same parameters currently exists.
-     *
-     * This should be used if multiple cache backends (and, thus,
-     * multiple Horde_Cache instances) are required.
-     *
-     * This method must be invoked as:
-     *   $var = Horde_Cache::singleton()
-     *
-     * @param mixed $driver  The type of concrete Horde_Cache subclass to
-     *                       return. If $driver is an array, then we will look
-     *                       in $driver[0]/lib/Cache/ for the subclass
-     *                       implementation named $driver[1].php.
-     * @param array $params  A hash containing any additional configuration or
-     *                       connection parameters a subclass might need.
-     *
-     * @return Horde_Cache  The concrete Horde_Cache reference.
-     * @throws Horde_Exception
-     */
-    static public function singleton($driver, $params = array())
-    {
-        ksort($params);
-        $signature = hash('md5', serialize(array($driver, $params)));
-
-        if (!isset(self::$_instances[$signature])) {
-            self::$_instances[$signature] = self::factory($driver, $params);
-        }
-
-        return self::$_instances[$signature];
-    }
-
 }
index 87759f4..09efe86 100644 (file)
  *   'port'         The port on which to connect to the database.</pre>
  *
  * Optional parameters:<pre>
- *   'table'               The name of the cache table in 'database'.
- *                         Defaults to 'horde_cache'.
- *   'use_memorycache'     Use a Horde_Cache:: memory caching driver to cache
- *                         the data (to avoid DB accesses).  Either empty or
- *                         'none' if not needed, or else the name of a valid
- *                         Horde_Cache:: driver.</pre>
+ *   'table'             The name of the cache table in 'database'.
+ *                       Defaults to 'horde_cache'.
+ *   'use_memorycache'   Use this Horde_Cache:: memory caching object to cache
+ *                       the data (to avoid DB accesses).</pre>
  *
  * Optional values when using separate reading and writing servers, for example
  * in replication settings:<pre>
@@ -104,9 +102,8 @@ class Horde_Cache_Sql extends Horde_Cache_Base
             $this->_params['table'] = 'horde_cache';
         }
 
-        /* Create the memory cache object, if configured. */
         if (!empty($this->_params['use_memorycache'])) {
-            $this->_mc = Horde_Cache::singleton($params['use_memorycache'], !empty($conf['cache'][$params['use_memorycache']]) ? $conf['cache'][$params['use_memorycache']] : array());
+            $this->_mc = $this->_params['use_memorycache'];
         }
 
         parent::__construct($this->_params);
index 3163080..e74c9f7 100644 (file)
@@ -338,7 +338,7 @@ HTML;
         }
 
         if ($driver == 'horde_cache') {
-            $cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], self::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+            $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
             $cache_lifetime = empty($conf['cachejsparams']['lifetime'])
                 ? 0
                 : $conf['cachejsparams']['lifetime'];
@@ -1716,7 +1716,7 @@ HTML;
                 break;
 
             case 'horde_cache':
-                $cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], self::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+                $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
 
                 // Do lifetime checking here, not on cache display page.
                 $exists = $cache->exists($sig, empty($GLOBALS['conf']['cachecssparams']['lifetime']) ? 0 : $GLOBALS['conf']['cachecssparams']['lifetime']);
index 2370355..f704c2a 100644 (file)
@@ -3,30 +3,35 @@ class Horde_Core_Binder_Cache implements Horde_Injector_Binder
 {
     public function create(Horde_Injector $injector)
     {
-        $driver = $GLOBALS['conf']['cache']['driver'];
+        return $this->_getCacheInstance($GLOBALS['conf']['cache']['driver'], $injector);
+    }
+
+    protected function _getCacheInstance($driver, $injector)
+    {
         $params = Horde::getDriverConfig('cache', $driver);
 
         if (is_array($driver)) {
             list($app, $driver_name) = $driver;
-            $driver = basename($driver_name);
         } else {
-            $driver = basename($driver);
+            $app = 'Horde';
+            $driver_name = basename($driver);
         }
 
-        if (empty($driver) || ($driver == 'none')) {
-            return new Horde_Cache_Null($params);
-        }
-
-        if ($driver == 'memcache') {
-            $params['memcache'] = $injector->getInstance('Horde_Memcache');
-        }
+        if (strtolower($app) == 'horde') {
+            switch (strtolower($driver)) {
+            case 'memcache':
+                $params['memcache'] = $injector->getInstance('Horde_Memcache');
+                break;
 
-        $class = (empty($app) ? 'Horde' : $app) . '_Cache_' . ucfirst($driver);
-        if (class_exists($class)) {
-            return new $class($params);
+            case 'sql':
+                if (!empty($params['use_memorycache'])) {
+                    $params['use_memorycache'] = $this->_getCacheInstance($params['use_memorycache'], $injector);
+                }
+                break;
+            }
         }
 
-        throw new Horde_Exception('Class definition of ' . $class . ' not found.');
+        return Horde_Cache::factory($driver, $params);
     }
 
     public function equals(Horde_Injector_Binder $binder)
index cdd2400..6a33dfd 100644 (file)
@@ -58,8 +58,7 @@ class Group_contactlists extends Group {
             }
         }
 
-        $this->_cache = &Horde_Cache::singleton(
-            $GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
     }
 
     /**
index 39e4584..da9c3b9 100644 (file)
@@ -5,10 +5,10 @@
  *
  * Requires Horde_Cache and Horde_Serialize packages.
  *
+ * <pre>
  * REQUIRED Parameters:
  * ====================
- * 'driver' - (string) The Horde_Cache driver to use.
- * 'driver_params' - (string) The params to pass to the Horde_Cache driver.
+ * 'cacheob' - (Horde_Cache) The cache object to use.
  * 'hostspec' - (string) The IMAP hostspec.
  * 'port' - (string) The IMAP port.
  * 'username' - (string) The IMAP username.
@@ -25,6 +25,7 @@
  *              DEFAULT: 1 week (604800 secs)
  * 'slicesize' - (integer) The slicesize to use.
  *               DEFAULT: 50
+ * </pre>
  *
  * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
  *
@@ -111,21 +112,15 @@ class Horde_Imap_Client_Cache
      * @param array $params  The configuration parameters.
      *
      * @throws Horde_Imap_Client_Exception
+     * @throws InvalidArgumentException
      */
     public function __construct($params = array())
     {
-        if (empty($params['driver']) ||
-            empty($params['driver_params']) ||
+        if (empty($params['cacheob']) ||
             empty($params['hostspec']) ||
             empty($params['port']) ||
             empty($params['username'])) {
-            throw new Horde_Imap_Client_Exception('Missing required parameters to Horde_Imap_Client_Cache.');
-        }
-
-        /* Initialize the Cache object. */
-        $this->_cache = Horde_Cache::singleton($params['driver'], $params['driver_params']);
-        if (is_a($this->_cache, 'PEAR_Error')) {
-            throw new Horde_Imap_Client_Exception($this->_cache->getMessage());
+            throw new InvalidArgumentException('Missing required parameters to Horde_Imap_Client_Cache.');
         }
 
         $compress = null;
@@ -149,6 +144,8 @@ class Horde_Imap_Client_Cache
             }
         }
 
+        $this->_cache = $params['cacheob'];
+
         $this->_params = array(
             'compress' => $compress,
             'debug' => empty($params['debug']) ? false : $params['debug'],
index a1cb93c..7fe5bc4 100644 (file)
@@ -149,13 +149,12 @@ class Horde_Kolab_Storage
         if (!empty($GLOBALS['conf']['kolab']['storage']['cache']['folders'])) {
             $signature = hash('md5', serialize(array($driver, $params))) . '|list';
 
-            $this->_cache = &Horde_Cache::singleton($GLOBALS['conf']['kolab']['storage']['cache']['folders']['driver'],
-                                                    $GLOBALS['conf']['kolab']['storage']['cache']['folders']['params']);
+            $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
 
             $data = $this->_cache->get($signature,
                                        $GLOBALS['conf']['kolab']['storage']['cache']['folders']['lifetime']);
             if ($data) {
-                $list = @unserialize($data);
+                $list = @unserialize($data);;
                 if ($list instanceOf Horde_Kolab_Storage) {
                     register_shutdown_function(array($list, 'shutdown'));
                     return $list;
index 6ef0e5f..8b65e8c 100644 (file)
@@ -152,7 +152,7 @@ class Horde_Kolab_Storage_Cache
                 $params = $GLOBALS['conf']['kolab']['storage']['cache']['data']['params'];
             }
         }
-        $this->horde_cache = Horde_Cache::singleton($driver, $params);
+        $this->horde_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
     }
 
     /**
index 397cd0d..303f7ba 100644 (file)
@@ -61,8 +61,7 @@ class Horde_Perms_Datatree extends Horde_Perms
                                                array_merge(Horde::getDriverConfig('datatree', $driver),
                                                            array('group' => 'horde.perms')));
 
-        $this->_cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                               Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
 
         parent::__construct();
     }
index a81cd6c..7517a03 100644 (file)
@@ -554,7 +554,7 @@ class Horde_Perms_Permission_DataTreeObject extends DataTreeObject
 
         parent::save();
 
-        $cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
         $cache->expire('perm_' . $name);
         $cache->expire('perm_exists_' . $name);
     }
index 7e5e7bb..7fb6f04 100644 (file)
@@ -77,7 +77,7 @@ class Horde_Perms_Permission_SqlObject extends Horde_Perms_Permission
             throw new Horde_Perms_Exception($result);
         }
 
-        $cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
         $cache->expire('perm_sql_' . $name);
         $cache->expire('perm_sql_exists_' . $name);
     }
index 4b96887..c843f30 100644 (file)
@@ -62,7 +62,7 @@ class Horde_Perms_Sql extends Horde_Perms
      */
     public function __construct()
     {
-        $this->_cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
     }
 
     /**
index 876ea2d..85c34d1 100644 (file)
@@ -109,7 +109,7 @@ class Horde_Template
         }
 
         try {
-            $this->_cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+            $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
         } catch (Horde_Exception $e) {}
     }
 
index ddbccde..7cf2cb4 100644 (file)
@@ -1428,8 +1428,8 @@ EOT;
         }
 
         $cid = md5($var->type->getText());
-        $cache = &Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                         Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
+
         $cache->set($cid, serialize(array('data' => $captcha->getCAPTCHAAsJPEG(),
                                           'ctype' => 'image/jpeg')));
 
index 0440eb8..3a62c46 100644 (file)
@@ -217,7 +217,7 @@ class Gollem
             ($conf['cache']['driver'] != 'none')) {
             $key = self::_getCacheID($dir);
 
-            $cache = Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
+            $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
             $res = $cache->get($key, $conf['foldercache']['lifetime']);
             if ($res !== false) {
                 $res = Horde_Serialize::unserialize($res, Horde_Serialize::BASIC);
@@ -268,7 +268,7 @@ class Gollem
         if (!empty($conf['foldercache']['use_cache']) &&
             !empty($conf['cache']['driver']) &&
             ($conf['cache']['driver'] != 'none')) {
-            $cache = Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
+            $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
             $cache->expire(self::_getCacheID($dir));
         }
     }
index 5a9883d..b6d6736 100644 (file)
@@ -13,8 +13,7 @@ class Horde_Block_Horde_feed_reader {
 
         $key = md5($uri);
 
-        $GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                                   Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $GLOBALS['cache'] = $GLOBALS['injector']->getInstance('Horde_Cache');
 
         $feed = $GLOBALS['cache']->get($key, $interval);
         if (!empty($feed)) {
index 8037b5b..2bd4cca 100644 (file)
@@ -265,8 +265,7 @@ EOF;
             return $this->_twitter;
         }
 
-        $cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                        Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
 
         if (!empty($GLOBALS['conf']['twitter']['key']) &&
             !empty($GLOBALS['conf']['twitter']['secret'])) {
index 615cf40..39dd9ca 100644 (file)
@@ -64,7 +64,7 @@ case 'js':
     }
 
     try {
-        $cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $cache = $injector->getInstance('Horde_Cache');
     } catch (Horde_Exception $e) {
         exit;
     }
index 82278cb..cb5008f 100644 (file)
@@ -16,7 +16,7 @@ if (empty($cid)) {
     exit;
 }
 
-$cache = Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
+$cache = $injector->getInstance('Horde_Cache');
 $cdata = @unserialize($cache->get($cid, $conf['cache']['default_lifetime']));
 if (!$cdata) {
     exit;
index b7d27a5..805149d 100644 (file)
@@ -18,9 +18,8 @@ if (empty($GLOBALS['conf']['twitter']['enabled'])) {
     exit;
 }
 
-/* Create a cahce object for the twitter client */
-$cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+/* Create a cache object for the twitter client */
+$cache = $injector->getInstance('Horde_Cache');
 
 /* Using OAuth or Http Basic? */
 if (!empty($GLOBALS['conf']['twitter']['key']) && !empty($GLOBALS['conf']['twitter']['secret'])) {
index 0f91bac..b7e3e4d 100644 (file)
@@ -14,7 +14,7 @@ $page = Horde_Util::getFormData('page');
 $preview = Horde_Util::getFormData('preview');
 
 /* Set up the cache object. */
-$cache = Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
+$cache = $injector->getInstance('Horde_Cache');
 
 /* Call the get the image data using cache. */
 $id = $fax_id . '_' . $page . ($preview ? '_p' : '');
index 1d7a4b9..b3a8164 100644 (file)
@@ -171,7 +171,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
 
         /* If there is a cache driver configured, try to get the public key
          * from the cache. */
-        if (empty($options['nocache']) && ($cache = IMP::getCache())) {
+        if (empty($options['nocache']) && ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) {
             $result = $cache->get("PGPpublicKey_" . $address . $keyid, 3600);
             if ($result) {
                 Horde::logMessage('PGPpublicKey: ' . serialize($result), __FILE__, __LINE__, PEAR_LOG_DEBUG);
index cf31ffc..21571cf 100644 (file)
@@ -105,7 +105,7 @@ class IMP_Folder
            obtain it. */
         $cache = null;
         if (is_null($this->_listCache)) {
-            if (!is_null($this->_cacheid) && ($cache = IMP::getCache())) {
+            if (!is_null($this->_cacheid) && ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) {
                 $ret = $cache->get($this->_cacheid, 3600);
                 if (!empty($ret)) {
                     $this->_listCache = unserialize($ret);
@@ -159,7 +159,7 @@ class IMP_Folder
      */
     public function clearFlistCache()
     {
-        if (!is_null($this->_cacheid) && ($cache = IMP::getCache())) {
+        if (!is_null($this->_cacheid) && ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) {
             $cache->expire($this->_cacheid);
         }
         $this->_listCache = array();
index 4e2a866..8edffc5 100644 (file)
@@ -1049,21 +1049,6 @@ class IMP
     }
 
     /**
-     * Returns a Horde_Cache object (if configured) and handles any errors
-     * associated with creating the object.
-     *
-     * @return mixed  A Horde_Cache object or null.
-     * @throws Horde_Exception
-     */
-    public static function getCache()
-    {
-        $cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
-        return ($cache instanceof Horde_Cache_Null)
-            ? null
-            : $cache;
-    }
-
-    /**
      * Generate the JS code necessary to open a passphrase dialog. Adds the
      * necessary JS files to open the dialog.
      *
index a881cdb..abbaf03 100644 (file)
@@ -225,8 +225,7 @@ class IMP_Imap
      */
     public function loadCacheConfig($config)
     {
-        $driver = $GLOBALS['conf']['cache']['driver'];
-        if ($driver == 'none') {
+        if (!($ob = $GLOBALS['injector']->getInstance('Horde_Cache'))) {
             return array();
         }
 
@@ -239,9 +238,8 @@ class IMP_Imap
         }
 
         return array(
+            'cacheob' => $ob,
             'compress' => empty($config['compress']) ? false : $config['compress'],
-            'driver' => $driver,
-            'driver_params' => Horde::getDriverConfig('cache', $driver),
             'lifetime' => empty($config['lifetime']) ? false : $config['lifetime'],
             'slicesize' => empty($config['slicesize']) ? false : $config['slicesize'],
         );
index 58a5ee4..d1bf571 100644 (file)
@@ -216,8 +216,7 @@ class IMP_Imap_Tree
     {
         if (!isset(self::$_instance)) {
             if (!empty($_SESSION['imp']['cache']['tree'])) {
-                $imp_cache = IMP::getCache();
-                self::$_instance = @unserialize($imp_cache->get($_SESSION['imp']['cache']['tree'], 86400));
+                self::$_instance = @unserialize($GLOBALS['injector']->getInstance('Horde_Cache')->get($_SESSION['imp']['cache']['tree'], 86400));
             }
 
             if (empty(self::$_instance)) {
@@ -242,7 +241,7 @@ class IMP_Imap_Tree
                 : $ns;
         }
 
-        if ($imp_cache = IMP::getCache()) {
+        if ($imp_cache = $GLOBALS['injector']->getInstance('Horde_Cache')) {
             $_SESSION['imp']['cache']['tree'] = uniqid(mt_rand() . Horde_Auth::getAuth());
         }
 
@@ -276,8 +275,7 @@ class IMP_Imap_Tree
          * has changed. */
         if (!empty($this->_changed) &&
             isset($_SESSION['imp']['cache']['tree'])) {
-            $imp_cache = IMP::getCache();
-            $imp_cache->set($_SESSION['imp']['cache']['tree'], serialize($this), 86400);
+            $GLOBALS['injector']->getInstance('Horde_Cache')->set($_SESSION['imp']['cache']['tree'], serialize($this), 86400);
         }
     }
 
index 2f5e81a..2feba13 100644 (file)
@@ -40,8 +40,7 @@ class Horde_Block_news_my_comments extends Horde_Block {
             return '';
         }
 
-        $GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                           Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $GLOBALS['cache'] = $GLOBALS['injector']->getInstance('Horde_Cache');
 
         $cache_key = 'news_myscommetns_' . $this->_params['limit'];
         $threads = $GLOBALS['cache']->get($cache_key, $GLOBALS['conf']['cache']['default_lifetime']);
index b0ce4f4..e1b10f4 100644 (file)
@@ -42,8 +42,7 @@ if (!defined('NEWS_BASE')) {
 }
 
 // Cache
-$GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
-                                           Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+$GLOBALS['cache'] = $injector->getInstance('Horde_Cache');
 
 // Set up News drivers.
 $GLOBALS['news'] = News_Driver::factory();
index 86d512c..c965463 100644 (file)
@@ -64,7 +64,7 @@ class Operator_Application extends Horde_Registry_Application
         $this->driver = Operator_Driver::factory();
 
         // Caching system for storing DB results
-        $GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+        $GLOBALS['cache'] = $GLOBALS['injector']->getInstance('Horde_Cache');
     }
 
     /**
index b24c521..4bfc8e1 100644 (file)
@@ -447,7 +447,7 @@ class Turba_Driver_Imsp extends Turba_Driver
         $searchop = $criteria['op'];
         $hasName = false;
         $this->_noGroups = false;
-        $cache = &Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
+        $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
         $key = implode(".", array_merge($criteria, array($this->_bookName)));
 
         /* Now make sure we aren't searching on a dynamically created