Permalink
Browse files

assert that the cache does not silently fail

  • Loading branch information...
dereuromark committed Jan 7, 2013
1 parent 9675265 commit 05167a6420b765b8f9ba7782a62ba1f5d9604512
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/Cake/Cache/Cache.php
View
@@ -154,20 +154,20 @@ protected static function _buildEngine($name) {
$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;
}
/**

0 comments on commit 05167a6

Please sign in to comment.