MDL-47208 core_availability: Return false when cm isnt in modinfo list
If a cm isn't in modinfo's cm list, then the user shouldn't be able to see that cm. This fixes an issue where hidden activities would cause users to be unable to use moodle.
This commit is contained in:
@@ -205,6 +205,13 @@ class info_module extends info {
|
||||
// As a result we cannot take short cuts any longer and must get
|
||||
// standard modinfo.
|
||||
$modinfo = get_fast_modinfo($cm->course, $userid);
|
||||
return $modinfo->get_cm($cm->id)->uservisible;
|
||||
$cms = $modinfo->get_cms();
|
||||
if (!isset($cms[$cm->id])) {
|
||||
// In some cases this might get called with a cmid that is no longer
|
||||
// available, for example when a module is hidden at system level.
|
||||
debugging('info_module::is_user_visible called with invalid cmid ' . $cm->id, DEBUG_DEVELOPER);
|
||||
return false;
|
||||
}
|
||||
return $cms[$cm->id]->uservisible;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user