Optimize theme recognition (#3220)
Credit to @vojtasvoboda. Will avoid asking the database for the currently active theme if there is only one theme present and its code matches the code set in cms.activeTheme
This commit is contained in:
parent
33d149fe1a
commit
bafd057f8c
|
|
@ -150,8 +150,12 @@ class Theme
|
|||
public static function getActiveThemeCode()
|
||||
{
|
||||
$activeTheme = Config::get('cms.activeTheme');
|
||||
$themes = static::all();
|
||||
$havingMoreThemes = count($themes) > 1;
|
||||
$themeHasChanged = !empty($themes[0]) && $themes[0]->dirName !== $activeTheme;
|
||||
$checkDatabase = $havingMoreThemes || $themeHasChanged;
|
||||
|
||||
if (App::hasDatabase()) {
|
||||
if ($checkDatabase && App::hasDatabase()) {
|
||||
try {
|
||||
try {
|
||||
$dbResult = Cache::remember(self::ACTIVE_KEY, 1440, function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue