From 00dadbe16475417f644c420611ac4c8714951aad Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Tue, 2 Mar 2010 11:51:36 +0000 Subject: [PATCH] MDL-21742 fixed serious regressions - require_login(); could not be called after setting up themes (we need this in several places, this will be improved later) + it is too late to set up default local in require_login() because some scripts may not even call this - such as CLI --- lib/moodlelib.php | 8 +++----- lib/setup.php | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 17e603c4264..d4d438c12da 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2131,15 +2131,13 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu } } if ($cm) { - $PAGE->set_cm($cm, $course); + $PAGE->set_cm($cm, $course); // set's up global $COURSE $PAGE->set_pagelayout('incourse'); } else { - $PAGE->set_course($course); + $PAGE->set_course($course); // set's up global $COURSE } } else { - // If $PAGE->course, and hence $PAGE->context, have not already been set - // up properly, set them up now. - $PAGE->set_course($PAGE->course); + // do not touch global $COURSE via $PAGE->set_course() !! } /// If the user is not even logged in yet then make sure they are diff --git a/lib/setup.php b/lib/setup.php index 4f911cd8832..1fc86deaca3 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -586,11 +586,9 @@ if (empty($CFG->lang)) { } } -// We used to call moodle_setlocale() and theme_setup() here, even though they -// would be called again from require_login or $PAGE->set_course. As an experiment -// I am going to try removing those calls. With luck it will help us find and -// fix a few bugs where scripts do not initialise things properly, without causing -// too much grief. +// Set the default site locale, a lot of the stuff may depend on this +// it is definitely too late to call this first in require_login()! +moodle_setlocale(); if (!empty($CFG->debugvalidators) and !empty($CFG->guestloginbutton)) { if ($CFG->theme == 'standard' or $CFG->theme == 'standardwhite') { // Temporary measure to help with XHTML validation -- 2.36.1