Permalink
Browse files

MDL-29862 incorrect wwwroot must be detected before session start

  • Loading branch information...
1 parent e04dba0 commit 06f72d26d72156052f58b760ce7b6f27cf9b8d9d @skodak skodak committed Oct 21, 2011
Showing with 9 additions and 5 deletions.
  1. +3 −4 lib/setup.php
  2. +6 −1 lib/setuplib.php
View
7 lib/setup.php
@@ -663,6 +663,9 @@ function stripslashes_deep($value) {
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 @@ function stripslashes_deep($value) {
$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');
View
7 lib/setuplib.php
@@ -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);
}
}

0 comments on commit 06f72d2

Please sign in to comment.