From: Michael J. Rubinsky Date: Thu, 27 May 2010 22:12:56 +0000 (-0400) Subject: get rid of the cache global in ansel, use injector instead. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a0d52a3a6506d38ea839a39deed40e48256ab86f;p=horde.git get rid of the cache global in ansel, use injector instead. --- diff --git a/ansel/gallery.php b/ansel/gallery.php index 4d871daa4..ad4ab18d5 100644 --- a/ansel/gallery.php +++ b/ansel/gallery.php @@ -273,7 +273,7 @@ case 'save': // Clear the OtherGalleries widget cache if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_OtherGalleries' . $gallery->get('owner')); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner')); } // Return to the last view. diff --git a/ansel/gallery/delete.php b/ansel/gallery/delete.php index e46b0a313..7a9f2920a 100644 --- a/ansel/gallery/delete.php +++ b/ansel/gallery/delete.php @@ -45,7 +45,7 @@ if ($galleryId) { // Clear the OtherGalleries widget cache if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_OtherGalleries' . $gallery->get('owner')); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner')); } // Return to the default view. diff --git a/ansel/lib/Application.php b/ansel/lib/Application.php index 932dd56ce..f32605149 100644 --- a/ansel/lib/Application.php +++ b/ansel/lib/Application.php @@ -61,11 +61,6 @@ class Ansel_Application extends Horde_Registry_Application throw new Horde_Exception('You must configure a Horde_Image driver to use Ansel'); } - // Create a cache object if we need it. - if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache'] = $GLOBALS['injector']->getInstance('Horde_Cache'); - } - // Create db, share, and vfs instances. $GLOBALS['ansel_db'] = Ansel::getDb(); $GLOBALS['ansel_storage'] = new Ansel_Storage(); diff --git a/ansel/lib/Faces/Base.php b/ansel/lib/Faces/Base.php index 9ba5293c6..104bef2bd 100644 --- a/ansel/lib/Faces/Base.php +++ b/ansel/lib/Faces/Base.php @@ -587,7 +587,7 @@ class Ansel_Faces_Base // Expire gallery cache if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_Gallery' . $gallery->id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $gallery->id); } return $fids; diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index 60aabc943..39353cc7e 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -136,7 +136,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical } if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_Gallery' . $this->id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $this->id); } return parent::_save(); @@ -187,7 +187,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical /* Need to expire the cache for the gallery that was changed */ if ($GLOBALS['conf']['ansel_cache']['usecache']) { $id = (is_null($gallery_id) ? $this->id : $gallery_id); - $GLOBALS['cache']->expire('Ansel_Gallery' . $id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $id); } return true; @@ -933,7 +933,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical $data = $this->_shareOb->_toDriverCharset(array($driver_key => $value)); $query = $db->prepare('UPDATE ' . $this->_shareOb->getTable() . ' SET ' . $driver_key . ' = ? WHERE share_id = ?', null, MDB2_PREPARE_MANIP); if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_Gallery' . $this->id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $this->id); } $result = $query->execute(array($data[$driver_key], $this->id)); $query->free(); diff --git a/ansel/lib/GalleryMode/Date.php b/ansel/lib/GalleryMode/Date.php index bf277f82c..b62433067 100644 --- a/ansel/lib/GalleryMode/Date.php +++ b/ansel/lib/GalleryMode/Date.php @@ -459,8 +459,8 @@ class Ansel_GalleryMode_Date /* Expire the cache since we have no reason to save() the gallery */ if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_Gallery' . $gallery->id); - $GLOBALS['cache']->expire('Ansel_Gallery' . $this->_gallery->id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $gallery->id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $this->_gallery->id); } return true; diff --git a/ansel/lib/GalleryMode/Normal.php b/ansel/lib/GalleryMode/Normal.php index 4054cc862..0f1d76bed 100644 --- a/ansel/lib/GalleryMode/Normal.php +++ b/ansel/lib/GalleryMode/Normal.php @@ -203,8 +203,8 @@ class Ansel_GalleryMode_Normal { /* Expire the cache since we have no reason to save() the gallery */ if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_Gallery' . $gallery->id); - $GLOBALS['cache']->expire('Ansel_Gallery' . $this->_gallery->id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $gallery->id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $this->_gallery->id); } return true; diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index 621f0975b..a388ce021 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -152,7 +152,7 @@ class Ansel_Storage /* Clear the parent from the cache */ if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_Gallery' . $parent); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $parent); } } @@ -321,7 +321,7 @@ class Ansel_Storage } if (!count($overrides) && $GLOBALS['conf']['ansel_cache']['usecache'] && - ($gallery = $GLOBALS['cache']->get('Ansel_Gallery' . $gallery_id, $GLOBALS['conf']['cache']['default_lifetime'])) !== false) { + ($gallery = $GLOBALS['injector']->getInstance('Horde_Cache')->get('Ansel_Gallery' . $gallery_id, $GLOBALS['conf']['cache']['default_lifetime'])) !== false) { $this->_galleries[$gallery_id] = unserialize($gallery); @@ -338,7 +338,7 @@ class Ansel_Storage // Don't cache if we have overridden anything if (!count($overrides)) { if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->set('Ansel_Gallery' . $gallery_id, serialize($result)); + $GLOBALS['injector']->getInstance('Horde_Cache')->set('Ansel_Gallery' . $gallery_id, serialize($result)); } } else { foreach ($overrides as $key => $value) { @@ -410,7 +410,7 @@ class Ansel_Storage // Clear the OtherGalleries widget cache if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_OtherGalleries' . $gallery->get('owner')); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner')); } } @@ -450,7 +450,7 @@ class Ansel_Storage /* Expire the cache */ if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_Gallery' . $id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $id); } unset($this->_galleries[$id]); @@ -459,7 +459,7 @@ class Ansel_Storage if (!$parent->countChildren(Horde_Perms::SHOW, false)) { $parent->set('has_subgalleries', 0, true); if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire('Ansel_Gallery' . $parent->id); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $parent->id); } unset($this->_galleries[$id]); } diff --git a/ansel/lib/Tags.php b/ansel/lib/Tags.php index 40f795a4e..64c28a14d 100644 --- a/ansel/lib/Tags.php +++ b/ansel/lib/Tags.php @@ -135,9 +135,9 @@ class Ansel_Tags if (is_array($tags) && count($tags) == 0) { return array(); } - if (isset($GLOBALS['cache'])) { + if ($GLOBALS['conf']['ansel_cache']['usecache']) { $cache_key = 'ansel_taginfo_' . (!is_null($tags) ? md5(serialize($tags) . $limit) : $limit); - $cvalue = $GLOBALS['cache']->get($cache_key, $conf['cache']['default_lifetime']); + $cvalue = $GLOBALS['injector']->getInstance('Horde_Cache')->get($cache_key, $conf['cache']['default_lifetime']); if ($cvalue) { return unserialize($cvalue); } @@ -156,8 +156,8 @@ class Ansel_Tags $results[$id]['tag_name'] = Horde_String::convertCharset( $taginfo['tag_name'], $GLOBALS['conf']['sql']['charset']); } - if (isset($GLOBALS['cache'])) { - $GLOBALS['cache']->set($cache_key, serialize($results)); + if ($GLOBALS['conf']['ansel_cache']['usecache']) { + $GLOBALS['injector']->getInstance('Horde_Cache')->set($cache_key, serialize($results)); } return $results; @@ -184,9 +184,9 @@ class Ansel_Tags $skey = md5(serialize($ids) . $from . $resource_type . $max . $user); - if (isset($GLOBALS['cache'])) { + if ($GLOBALS['conf']['ansel_cache']['usecache']) { $key = Horde_Auth::getAuth() . '__anseltagsearches'; - $cvalue = $GLOBALS['cache']->get($key, 300); + $cvalue = $GLOBALS['injector']->getInstance('Horde_Cache')->get($key, 300); $cvalue = @unserialize($cvalue); if (!$cvalue) { $cvalue = array(); @@ -260,9 +260,9 @@ class Ansel_Tags } } - if (isset($GLOBALS['cache'])) { + if ($GLOBALS['conf']['ansel_cache']['usecache']) { $cvalue[$skey] = $results; - $GLOBALS['cache']->set($key, serialize($cvalue)); + $GLOBALS['injector']->getInstance('Horde_Cache')->set($key, serialize($cvalue)); } return $results; @@ -448,7 +448,7 @@ class Ansel_Tags static public function clearCache() { if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->expire(Horde_Auth::getAuth() . '__anseltagsearches'); + $GLOBALS['injector']->getInstance('Horde_Cache')->expire(Horde_Auth::getAuth() . '__anseltagsearches'); } } } diff --git a/ansel/lib/Widget/OtherGalleries.php b/ansel/lib/Widget/OtherGalleries.php index c3bf0c9f0..f75eab952 100644 --- a/ansel/lib/Widget/OtherGalleries.php +++ b/ansel/lib/Widget/OtherGalleries.php @@ -39,13 +39,13 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base public function html() { if ($GLOBALS['conf']['ansel_cache']['usecache'] && - ($widget = $GLOBALS['cache']->get('Ansel_OtherGalleries' . $this->_view->gallery->get('owner'))) !== false) { + ($widget = $GLOBALS['injector']->getInstance('Horde_Cache')->get('Ansel_OtherGalleries' . $this->_view->gallery->get('owner'))) !== false) { return $widget; } $widget = $this->_htmlBegin() . $this->_getOtherGalleries() . $this->_htmlEnd(); if ($GLOBALS['conf']['ansel_cache']['usecache']) { - $GLOBALS['cache']->set('Ansel_OtherGalleries' . $this->_view->gallery->get('owner'), $widget); + $GLOBALS['injector']->getInstance('Horde_Cache')->set('Ansel_OtherGalleries' . $this->_view->gallery->get('owner'), $widget); } return $widget; diff --git a/ansel/rss.php b/ansel/rss.php index 8ddff7203..1f95e4e88 100644 --- a/ansel/rss.php +++ b/ansel/rss.php @@ -22,8 +22,8 @@ $uid = md5($stream_type . $id . $type . Horde_Auth::getAuth()); $filename = 'ansel_feed_template_' . $uid; if ($conf['ansel_cache']['usecache']) { $cache_key = 'ansel_feed_template_' . $uid; - $rss = $cache->get($cache_key, $conf['cache']['default_lifetime']); - $filename = $cache->get($filename, $conf['cache']['default_lifetime']); + $rss = $GLOBALS['injector']->getInstance('Horde_Cache')->get($cache_key, $conf['cache']['default_lifetime']); + $filename = $GLOBALS['injector']->getInstance('Horde_Cache')->get($filename, $conf['cache']['default_lifetime']); } if (empty($rss)) { @@ -290,8 +290,8 @@ if (empty($rss)) { $rss = ob_get_clean(); if ($conf['ansel_cache']['usecache']) { - $cache->set($cache_key, $rss); - $cache->set($filename, $params['name']); + $GLOBALS['injector']->getInstance('Horde_Cache')->set($cache_key, $rss); + $GLOBALS['injector']->getInstance('Horde_Cache')->set($filename, $params['name']); } }