MDL-25981 make sure cm is defined

This commit is contained in:
Petr Skoda 2011-01-31 22:19:36 +01:00
parent 0d8b6a69ce
commit d4fb0e26e2

View File

@ -2654,7 +2654,7 @@ function require_course_login($courseorid, $autologinguest = true, $cm = NULL, $
global $CFG, $PAGE, $SITE;
$issite = (is_object($courseorid) and $courseorid->id == SITEID)
or (!is_object($courseorid) and $courseorid == SITEID);
if ($issite && !($cm instanceof cm_info)) {
if ($issite && !empty($cm) && !($cm instanceof cm_info)) {
// note: nearly all pages call get_fast_modinfo anyway and it does not make any
// db queries so this is not really a performance concern, however it is obviously
// better if you use get_fast_modinfo to get the cm before calling this.