Merge branch 'MDL-82171-muc-sited-MOODLE_404_STABLE' of https://github.com/brendanheywood/moodle into MOODLE_404_STABLE

This commit is contained in:
Ilya Tregubov
2024-08-05 11:18:59 +08:00
3 changed files with 38 additions and 9 deletions
+15 -5
View File
@@ -680,19 +680,29 @@ if (PHPUNIT_TEST and !PHPUNIT_UTIL) {
}
// Load any immutable bootstrap config from local cache.
$bootstrapcachefile = $CFG->localcachedir . '/bootstrap.php';
if (is_readable($bootstrapcachefile)) {
$bootstraplocalfile = $CFG->localcachedir . '/bootstrap.php';
$bootstrapsharedfile = $CFG->cachedir . '/bootstrap.php';
if (!is_readable($bootstraplocalfile) && is_readable($bootstrapsharedfile)) {
// If we don't have a local cache but do have a shared cache then clone it,
// for example when scaling up new front ends.
make_localcache_directory('', true);
copy($bootstrapsharedfile, $bootstraplocalfile);
}
if (is_readable($bootstraplocalfile)) {
try {
require_once($bootstrapcachefile);
require_once($bootstraplocalfile);
// Verify the file is not stale.
if (!isset($CFG->bootstraphash) || $CFG->bootstraphash !== hash_local_config_cache()) {
// Something has changed, the bootstrap.php file is stale.
unset($CFG->siteidentifier);
@unlink($bootstrapcachefile);
@unlink($bootstraplocalfile);
@unlink($bootstrapsharedfile);
}
} catch (Throwable $e) {
// If it is corrupted then attempt to delete it and it will be rebuilt.
@unlink($bootstrapcachefile);
@unlink($bootstraplocalfile);
@unlink($bootstrapsharedfile);
}
}