From 05167a6420b765b8f9ba7782a62ba1f5d9604512 Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 7 Jan 2013 13:43:21 +0100 Subject: [PATCH] assert that the cache does not silently fail --- lib/Cake/Cache/Cache.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Cache/Cache.php b/lib/Cake/Cache/Cache.php index 0278de176..7566e04ed 100644 --- a/lib/Cake/Cache/Cache.php +++ b/lib/Cake/Cache/Cache.php @@ -154,20 +154,20 @@ class Cache { $cacheClass = $class . 'Engine'; App::uses($cacheClass, $plugin . 'Cache/Engine'); if (!class_exists($cacheClass)) { - return false; + throw new CacheException(__d('cake_dev', 'Cache engine %s is not available.', $name)); } $cacheClass = $class . 'Engine'; if (!is_subclass_of($cacheClass, 'CacheEngine')) { throw new CacheException(__d('cake_dev', 'Cache engines must use CacheEngine as a base class.')); } self::$_engines[$name] = new $cacheClass(); - if (self::$_engines[$name]->init($config)) { - if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) { - self::$_engines[$name]->gc(); - } - return true; + if (!self::$_engines[$name]->init($config)) { + throw new CacheException(__d('cake_dev', 'Cache engine %s is not properly configured.', $name)); } - return false; + if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) { + self::$_engines[$name]->gc(); + } + return true; } /**