Catch IMAP caching init errors
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 7 Sep 2010 06:12:16 +0000 (00:12 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 7 Sep 2010 06:49:04 +0000 (00:49 -0600)
framework/Imap_Client/lib/Horde/Imap/Client/Base.php
framework/Imap_Client/lib/Horde/Imap/Client/Cache.php

index a94b276..bf61c7f 100644 (file)
@@ -233,7 +233,6 @@ abstract class Horde_Imap_Client_Base implements Serializable
      *                          mailbox.
      *
      * @return boolean  Returns true if caching is enabled.
-     * @throws Horde_Imap_Client_Exception
      */
     protected function _initCache($current = false)
     {
@@ -244,12 +243,16 @@ abstract class Horde_Imap_Client_Base implements Serializable
 
         if (is_null($this->cache)) {
             $p = $this->_params;
-            $this->cache = Horde_Imap_Client_Cache::singleton(array_merge($p['cache'], array(
-                'debug' => $this->_debug,
-                'hostspec' => $p['hostspec'],
-                'port' => $p['port'],
-                'username' => $p['username']
-            )));
+            try {
+                $this->cache = Horde_Imap_Client_Cache::singleton(array_merge($p['cache'], array(
+                    'debug' => $this->_debug,
+                    'hostspec' => $p['hostspec'],
+                    'port' => $p['port'],
+                    'username' => $p['username']
+                )));
+            } catch (InvalidArgumentException $e) {
+                return false;
+            }
         }
 
         if (!$current) {
index a9c46da..d38a233 100644 (file)
@@ -112,10 +112,9 @@ class Horde_Imap_Client_Cache
      *
      * @param array $params  The configuration parameters.
      *
-     * @throws Horde_Imap_Client_Exception
      * @throws InvalidArgumentException
      */
-    public function __construct($params = array())
+    public function __construct(array $params = array())
     {
         if (empty($params['cacheob']) ||
             empty($params['hostspec']) ||
@@ -148,7 +147,7 @@ class Horde_Imap_Client_Cache
             }
 
             if (is_null($compress)) {
-                throw new Horde_Imap_Client_Exception('Horde_Cache does not support the compression type given.');
+                throw new InvalidArgumentException('Horde_Cache does not support the compression type given.');
             }
         }