From 2f86a952d78beebf4bca7891f6ab97868e7bf0c9 Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Fri, 3 Jan 2014 14:59:11 +1100 Subject: [PATCH] MDL-43530 cache: Cache multiple different dirroots In some clustered environments (Amazon OpsWorks) the deployment folders on different nodes use different file paths. As we cache the realpath in the shared MUC, you don't always get the right answer. We now cache each dirroot in it's own full path location to allow each node to get the correct file locations for itself. --- lib/moodlelib.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 041d3a3b7d9..b3750e264cd 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -8227,14 +8227,9 @@ function get_plugin_types($fullpaths=true) { $cache = cache::make('core', 'plugintypes'); if ($fullpaths) { - // First confirm that dirroot and the stored dirroot match. - if ($CFG->dirroot === $cache->get('dirroot')) { - // They match we can use it. - $cached = $cache->get(1); - } else { - // Oops they didn't match. The moodle directory has been moved on us. - $cached = false; - } + // Cache each dirroot separately in case cluster nodes happen to be deployed to + // different locations. + $cached = $cache->get(sha1($CFG->dirroot)); } else { $cached = $cache->get(0); } @@ -8293,10 +8288,7 @@ function get_plugin_types($fullpaths=true) { } $cache->set(0, $info); - $cache->set(1, $fullinfo); - // We cache the dirroot as well so that we can compare it when we - // retrieve full info from the cache. - $cache->set('dirroot', $CFG->dirroot); + $cache->set(sha1($CFG->dirroot), $fullinfo); return ($fullpaths ? $fullinfo : $info); }