Install a third party activity plugin (for example this one: https://moodle.org/plugins/mod_attendance ) Create a course and add some core activities (forum, file...) and at least one activity from the type installed in step 1 Remove the activity plugin folder but do NOT uninstall it (we want the activities records in the DB) Go to site administration -> notifications. The system should detect the folder is missing and do some updates. Go to the course Check the course is displayed without the missing plugin activities.
- Install a third party activity plugin (for example this one: https://moodle.org/plugins/mod_attendance )
- Create a course and add some core activities (forum, file...) and at least one activity from the type installed in step 1
- Remove the activity plugin folder but do NOT uninstall it (we want the activities records in the DB)
- Go to site administration -> notifications. The system should detect the folder is missing and do some updates.
- Go to the course
- Check the course is displayed without the missing plugin activities.
We (seemingly) randomly had the following error :
line 236 of /lib/modinfolib.php: moodle_exception thrown
line 1890 of /lib/modinfolib.php: call to course_modinfo->get_cm()
line 1078 of /lib/completionlib.php: call to cm_info::create()
line 70 of /completion/classes/cm_completion_details.php: call to completion_info->get_data()
line 275 of /completion/classes/cm_completion_details.php: call to core_completion\cm_completion_details->__construct()
line 947 of /course/renderer.php: call to core_completion\cm_completion_details::get_instance()
line 836 of /course/renderer.php: call to core_course_renderer->course_section_cm()
line 1051 of /course/renderer.php: call to core_course_renderer->course_section_cm_list_item()
line 859 of /course/format/renderer.php: call to core_course_renderer->course_section_cm_list()
line 57 of /course/format/topics/format.php: call to format_section_renderer_base->print_multiple_section_page()
line 278 of /course/view.php: call to require()
By checking the offending data in one of the cases, here are some more details :
When code reaches this point $cmid equals 1128369 (mod_zoom), but $this->cms only contains (mod_forum).
When checking the course_modules DB table for this course, I find the correct two course modules :
> SELECT * FROM mdl_course_modules WHERE course = 21942;
Module 7 is mod_forum, whereas module 48 is mod_zoom.
I noticed that this involves some weird "ghost" module instance, having mdl_course_modules.instance = 0 (as per the example query result above).
So far, I've encountered cases involving mod_forum, mod_zoom, mod_scorm, and mod_assign – so it does not look like a bug related to any of these in particular.
Checking further, $this->cms never contains any of these "ghost" modules, and they are never displayed on the course page. Trying to force their display (by browsing to /mod/<modulename>/view.php?id=<cm.instance>) obviously does not work either – it yields the same exception in course_modinfo::get_cm().
I then checked what had changed on our Moodle installation recently, noting that I had just upgraded from Moodle 3.11.2 to 3.11.3 earlier on the same day.
Looking at the changes made in one of the fixed issues (from the [Moodle 3.11.3 release notes|https://docs.moodle.org/dev/Moodle_3.11_release_notes),] I noticed one that was related to improve performance of activity information (and completion) :
I then just reverted this line, and it seemed to fix the problem :