MDL-82171 core: Rewarm bootstrap.php after a cache purge
This commit is contained in:
+15
-5
@@ -675,19 +675,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user