If the cache should fail, don't bring down the whole app

This commit is contained in:
Samuel Georges 2016-04-27 05:44:02 +10:00
parent a5acbc7bff
commit adbde0ad09
1 changed files with 9 additions and 3 deletions

View File

@ -14,6 +14,7 @@ use October\Rain\Halcyon\Datasource\FileDatasource;
use ApplicationException;
use SystemException;
use DirectoryIterator;
use Exception;
/**
* This class represents the CMS theme.
@ -147,9 +148,14 @@ class Theme
$activeTheme = Config::get('cms.activeTheme');
if (App::hasDatabase()) {
$dbResult = Cache::remember(self::ACTIVE_KEY, 1440, function() {
return Parameters::applyKey(self::ACTIVE_KEY)->pluck('value');
});
try {
$dbResult = Cache::remember(self::ACTIVE_KEY, 1440, function() {
return Parameters::applyKey(self::ACTIVE_KEY)->pluck('value');
});
}
catch (Exception $ex) {
$dbResult = Parameters::applyKey(self::ACTIVE_KEY)->pluck('value');
}
if ($dbResult !== null && static::exists($dbResult)) {
$activeTheme = $dbResult;