From a6af674a9957346f0f50625a8d4ad00765eccbbd Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 23 Feb 2008 18:42:00 +0000 Subject: [PATCH] MDL-13613 added better detection for outdated course modinfo; merged from MOODLE_19_STABLE --- course/view.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/course/view.php b/course/view.php index 384b3b8264..4539d9c633 100644 --- a/course/view.php +++ b/course/view.php @@ -48,7 +48,7 @@ role_switch($switchrole, $context); } - require_login($course->id); + require_login($course); // Switchrole - sanity check in cost-order... if ($switchrole > 0 && confirm_sesskey() && @@ -186,8 +186,16 @@ // Course wrapper start. echo '
'; - $modinfo =& get_fast_modinfo($course); + $modinfo =& get_fast_modinfo($COURSE); get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); + foreach($mods as $modid=>$unused) { + if (!isset($modinfo->cms[$modid])) { + rebuild_course_cache($course->id); + $modinfo =& get_fast_modinfo($COURSE); + debugging('Rebuilding course cache', DEBUG_DEVELOPER); + break; + } + } if (! $sections = get_all_sections($course->id)) { // No sections found // Double-check to be extra sure -- 2.39.5