Project: moodle
Issue MDL-40436: Error in Courses block when the user is enrolled in courses from other servers by MNet
If user is enrolled in courses from other host (host 2) by mnet, and block "Courses" is activated in actual host (host 1), error shown : 'Can not find data record in database table course'. *Steps to reproduce:* # Enrol user (user A) in course from other host (host 2) by mnet # Activate block "Courses" in Home of host 1 # Access with user A in host 1 Error shown : 'Can not find data record in database table course'. This is because in file: {code:title=blocks/course_list/block_course_list.php, in function get_remote_courses()} $coursecontext = context_course::instance($course->id); {code} That's defined in the file : {code:title=lib/accesslib.php} ... if (!$record = $DB->get_record('context', array('contextlevel'=>CONTEXT_COURSE, 'instanceid'=>$instanceid))) { if ($course = $DB->get_record('course', array('id'=>$instanceid), 'id,category', $strictness)) { ... {code} but $course->id not in table 'course' because it is an MNet course. I think solution is commented: {code:title=blocks/course_list/block_course_list.php, get_remote_courses()} $coursecontext = context_course::instance($course->id); {code}
Story points: 5