From 33d149fe1aafe284fefe0b7c9558bbe75028ef8a Mon Sep 17 00:00:00 2001 From: Samuell Date: Wed, 25 Sep 2019 19:36:35 +0200 Subject: [PATCH] Replace caching of Theme config with generic YAML caching (#4526) Credit to @Samuell1. Fixes issues related to complexity of the existing approach / cache invalidation by just using the caching built in to YAML::parseFile(). --- modules/cms/classes/Theme.php | 18 +----------------- modules/system/traits/ConfigMaker.php | 2 +- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/modules/cms/classes/Theme.php b/modules/cms/classes/Theme.php index ca97b1100..0086ecc99 100644 --- a/modules/cms/classes/Theme.php +++ b/modules/cms/classes/Theme.php @@ -50,7 +50,6 @@ class Theme const ACTIVE_KEY = 'cms::theme.active'; const EDIT_KEY = 'cms::theme.edit'; - const CONFIG_KEY = 'cms::theme.config'; /** * Loads the theme. @@ -341,21 +340,7 @@ class Theme return $this->configCache = []; } - try { - if (Config::get('app.debug', false)) { - $config = Yaml::parseFile($path); - } else { - $cacheKey = self::CONFIG_KEY.'::'.$this->getDirName(); - $config = Cache::rememberForever($cacheKey, function () use ($path) { - return Yaml::parseFile($path); - }); - } - } - catch (Exception $ex) { - // Cache failed - $config = Yaml::parseFile($path); - } - + $config = Yaml::parseFile($path); /** * @event cms.theme.extendConfig @@ -505,7 +490,6 @@ class Theme Cache::forget(self::ACTIVE_KEY); Cache::forget(self::EDIT_KEY); - Cache::forget(self::CONFIG_KEY.'::'.(new self)->getDirName()); } /** diff --git a/modules/system/traits/ConfigMaker.php b/modules/system/traits/ConfigMaker.php index 92245ab83..9a78be8c3 100644 --- a/modules/system/traits/ConfigMaker.php +++ b/modules/system/traits/ConfigMaker.php @@ -65,7 +65,7 @@ trait ConfigMaker )); } - $config = Yaml::parse(File::get($configFile)); + $config = Yaml::parseFile($configFile); /* * Extensibility