MDL-29862 incorrect wwwroot must be detected before session start
This commit is contained in:
+3
-4
@@ -663,6 +663,9 @@ if (isset($_SERVER['PHP_SELF'])) {
|
||||
unset($phppos);
|
||||
}
|
||||
|
||||
// initialise ME's - this must be done BEFORE starting of session!
|
||||
initialise_fullme();
|
||||
|
||||
// init session prevention flag - this is defined on pages that do not want session
|
||||
if (CLI_SCRIPT) {
|
||||
// no sessions in CLI scripts possible
|
||||
@@ -685,10 +688,6 @@ session_get_instance();
|
||||
$SESSION = &$_SESSION['SESSION'];
|
||||
$USER = &$_SESSION['USER'];
|
||||
|
||||
// initialise ME's
|
||||
// This must presently come AFTER $USER has been set up.
|
||||
initialise_fullme();
|
||||
|
||||
// Late profiling, only happening if early one wasn't started
|
||||
if (!empty($CFG->profilingenabled)) {
|
||||
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
|
||||
|
||||
+6
-1
@@ -661,7 +661,7 @@ function initialise_cfg() {
|
||||
* setup.php.
|
||||
*/
|
||||
function initialise_fullme() {
|
||||
global $CFG, $FULLME, $ME, $SCRIPT, $FULLSCRIPT;
|
||||
global $CFG, $FULLME, $ME, $SCRIPT, $FULLSCRIPT, $USER;
|
||||
|
||||
// Detect common config error.
|
||||
if (substr($CFG->wwwroot, -1) == '/') {
|
||||
@@ -715,6 +715,11 @@ function initialise_fullme() {
|
||||
if (!defined('NO_MOODLE_COOKIES')) {
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
}
|
||||
if (!isset($USER->id)) {
|
||||
// MDL-27899 workaround
|
||||
$USER = new stdClass();
|
||||
$USER->id = 0;
|
||||
}
|
||||
redirect($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user