Better error handling if cache entries can not be deleted
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 24 Nov 2010 07:37:45 +0000 (00:37 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 24 Nov 2010 07:37:45 +0000 (00:37 -0700)
framework/Core/lib/Horde/Core/Factory/ThemesCache.php
horde/bin/themes

index e9a8940..b4188f1 100644 (file)
@@ -101,7 +101,8 @@ class Horde_Core_Factory_ThemesCache
      * @param string $app    The application name.
      * @param string $theme  The theme name.
      *
-     * @return boolean  True if cache entry existed.
+     * @return boolean  True if cache entry existed and was deleted.
+     * @throws Horde_Exception
      */
     public function expireCache($app, $theme)
     {
@@ -110,9 +111,11 @@ class Horde_Core_Factory_ThemesCache
         $cache = $this->_injector->getInstance('Horde_Cache');
 
         if ($cache->exists($sig, $GLOBALS['conf']['cachethemesparams']['lifetime'])) {
-            $cache->expire($sig);
-            unset($this->_instances[$sig]);
+            if (!$cache->expire($sig)) {
+                throw new Horde_Exception('Could not delete cache entry.');
+            }
 
+            unset($this->_instances[$sig]);
             return true;
         }
 
index ad86c3c..9990fdd 100755 (executable)
@@ -36,10 +36,16 @@ foreach ($options[0] as $val) {
             $tcache = $injector->getInstance('Horde_Core_Factory_ThemesCache');
             $tlist = array_keys(Horde_Themes::themeList());
 
+            $cli->writeln();
+
             foreach ($registry->listAllApps() as $app) {
                 foreach ($tlist as $theme) {
-                    if ($tcache->expireCache($app, $theme)) {
-                        $cli->message('Cache entry expired [APP: ' . $app . '; THEME: ' . $theme . ']');
+                    try {
+                        if ($tcache->expireCache($app, $theme)) {
+                            $cli->message('Cache entry expired [APP: ' . $app . '; THEME: ' . $theme . ']');
+                        }
+                    } catch (Horde_Exception $e) {
+                        $cli->message('Could not expire cache entry [APP: ' . $app . '; THEME: ' . $theme . ']', 'cli.warning');
                     }
                 }
             }