Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
a46aa000
Commit
a46aa000
authored
Nov 19, 2021
by
Shamim Rezaie
Browse files
Merge branch 'MDL-73098' of
https://github.com/stronk7/moodle
parents
357ddcaf
4c0ae3e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/setup.php
View file @
a46aa000
...
...
@@ -666,6 +666,12 @@ $bootstrapcachefile = $CFG->localcachedir . '/bootstrap.php';
if
(
is_readable
(
$bootstrapcachefile
))
{
try
{
require_once
(
$bootstrapcachefile
);
// 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
);
}
}
catch
(
Throwable
$e
)
{
// If it is corrupted then attempt to delete it and it will be rebuilt.
@
unlink
(
$bootstrapcachefile
);
...
...
lib/setuplib.php
View file @
a46aa000
...
...
@@ -809,7 +809,11 @@ function initialise_local_config_cache() {
$contents
=
"<?php
// ********** This file is generated DO NOT EDIT **********
\$
CFG->siteidentifier = '"
.
addslashes
(
$CFG
->
siteidentifier
)
.
"';
define('SYSCONTEXTID', "
.
SYSCONTEXTID
.
");
\$
CFG->bootstraphash = '"
.
hash_local_config_cache
()
.
"';
// Only if the file is not stale and has not been defined.
if (
\$
CFG->bootstraphash === hash_local_config_cache() && !defined('SYSCONTEXTID')) {
define('SYSCONTEXTID', "
.
SYSCONTEXTID
.
");
}
"
;
$temp
=
$bootstrapcachefile
.
'.tmp'
.
uniqid
();
...
...
@@ -819,6 +823,25 @@ define('SYSCONTEXTID', ".SYSCONTEXTID.");
}
}
/**
* Calculate a proper hash to be able to invalidate stale cached configs.
*
* Only to be used to verify bootstrap.php status.
*
* @return string md5 hash of all the sensible bits deciding if cached config is stale or no.
*/
function
hash_local_config_cache
()
{
global
$CFG
;
// This is pretty much {@see moodle_database::get_settings_hash()} that is used
// as identifier for the database meta information MUC cache. Should be enough to
// react against any of the normal changes (new prefix, change of DB type) while
// *incorrectly* keeping the old dataroot directory unmodified with stale data.
// This may need more stuff to be considered if it's discovered that there are
// more variables making the file stale.
return
md5
(
$CFG
->
dbtype
.
$CFG
->
dbhost
.
$CFG
->
dbuser
.
$CFG
->
dbname
.
$CFG
->
prefix
);
}
/**
* Initialises $FULLME and friends. Private function. Should only be called from
* setup.php.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment