diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 926128417935b3477a528a9d73edf1cb03de43bd..69add57dda46b8596dd782db592fc49fc548d3e8 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -181,4 +181,10 @@ class Class_AdminVar extends Storm_Model_Abstract { public static function getKnownVars() { return self::$_knownVars; } + + + /** @return bool */ + public static function isCacheEnabled() { + return self::isModuleEnabled('CACHE_ACTIF'); + } } \ No newline at end of file diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php index d0aabf8bb0e89f9e5141226b9557505f587fc3f6..7a88c6c0358e6fa1cc91076d05943ac5657d90ce 100644 --- a/library/Class/Catalogue.php +++ b/library/Class/Catalogue.php @@ -280,7 +280,7 @@ class Class_Catalogue extends Storm_Model_Abstract { public function getNoticesByPreferences($preferences,$cache_vignette=false) { $cache_key = md5(serialize($preferences).$cache_vignette); $cache = Zend_Registry::get('cache'); - if ($cache->test($cache_key)) { + if (Class_AdminVar::isCacheEnabled() && $cache->test($cache_key)) { $notices = unserialize($cache->load($cache_key)); } else { $notices = $this->_fetchAllNoticesByPreferences($preferences, $cache_vignette); diff --git a/tests/library/Class/CatalogueTest.php b/tests/library/Class/CatalogueTest.php index 0dea45b739cef6b8cc77d2abc5d3a75a6833a26a..29a308b41ddcb3821e9586e476c9c04cf7d443ce 100644 --- a/tests/library/Class/CatalogueTest.php +++ b/tests/library/Class/CatalogueTest.php @@ -389,6 +389,10 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::getLoader() + ->newInstanceWithId('CACHE_ACTIF') + ->setValeur(1); + $this->old_cache = Zend_Registry::get('cache'); $this->mock_cache = Storm_Test_ObjectWrapper::mock(); Zend_Registry::set('cache', $this->mock_cache);