From 00250bc4d6159d0ab546afb381ab7304501e8071 Mon Sep 17 00:00:00 2001 From: Frederik Milling Pytlick Date: Thu, 11 Jun 2026 15:37:42 +0200 Subject: [PATCH 1/2] Fix issue happening on every consecutive purgecache --- classes/cache_factory.php | 13 ++++++++++--- version.php | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/classes/cache_factory.php b/classes/cache_factory.php index 593afa7..5a2839f 100644 --- a/classes/cache_factory.php +++ b/classes/cache_factory.php @@ -53,14 +53,21 @@ public function create_config_instance($writer = false) { } } + $config = null; + if (!array_key_exists($class, $this->configs)) { // Create a new instance and call it to load it. // As part of generating store instance config we test the initialisation of stores. // Testing this may initialise DI, which will attempt to use cache for hookcallbacks. // Setting the state to initialising will make it use ad-hoc cache for that request. self::set_state(self::STATE_INITIALISING); - $this->configs[$class] = new $class; - $this->configs[$class]->load(); + $config = new $class(); + $config->load(); + + // Re-register after load in case anything reset $this->configs. + $this->configs[$class] = $config; + } else { + $config = $this->configs[$class]; } // We need the siteid in order to use the caches, but the siteid @@ -77,7 +84,7 @@ public function create_config_instance($writer = false) { } // Return the instance. - return $this->configs[$class]; + return $config; } /** diff --git a/version.php b/version.php index 6c9b941..6797c95 100644 --- a/version.php +++ b/version.php @@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024093000; -$plugin->release = "2024093000"; +$plugin->version = 2024093001; +$plugin->release = "2024093001"; $plugin->requires = 2024092700; // Requires 4.5. $plugin->component = 'tool_forcedcache'; // Full name of the plugin (used for diagnostics). $plugin->maturity = MATURITY_STABLE; From 461720b04a6b9e44b8bd44b1303fec8ec94ec695 Mon Sep 17 00:00:00 2001 From: Frederik Milling Pytlick Date: Thu, 11 Jun 2026 15:44:34 +0200 Subject: [PATCH 2/2] Also updated requires to actually point to Moodle 4.5.0 --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index 6797c95..57f9512 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ $plugin->version = 2024093001; $plugin->release = "2024093001"; -$plugin->requires = 2024092700; // Requires 4.5. +$plugin->requires = 2024100700; // Requires 4.5. $plugin->component = 'tool_forcedcache'; // Full name of the plugin (used for diagnostics). $plugin->maturity = MATURITY_STABLE; $plugin->supported = [405, 405];