Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-72566

Activity information performance enhancement could cause 'invalidcoursemodule' exception

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE
    • MDL-72566-master
    • Hide
      1. Install a third party activity plugin (for example this one: https://moodle.org/plugins/mod_attendance )
      2. Create a course and add some core activities (forum, file...) and at least one activity from the type installed in step 1
      3. Remove the activity plugin folder but do NOT uninstall it (we want the activities records in the DB)
      4. Go to site administration -> notifications. The system should detect the folder is missing and do some updates.
      5. Go to the course
        1. Check the course is displayed without the missing plugin activities.
      Show
      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 [1128368](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;

      id      course module instance section idnumber added      score indent visible visibleoncoursepage visibleold groupmode groupingid completion completiongradeitemnumber completionview completionexpected showdescription availability deletioninprogress
      1128368   21942       7     38890   277352 NULL     1599468499     0       0       1                   1           1         0           0           0                       NULL               0                   0               0 NULL                           0
      1128369   21942     48         0   277352           1600084544     0       0       0                   1           0         0           0           1                       NULL               0                   0               0 NULL                           0

      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) : MDL-71899.

      I then just reverted this line, and it seemed to fix the problem :

      https://github.com/HuongNV13/moodle/compare/7fdf72a268...MDL-71899-311-2#diff-37fe4a6388ccfbca35d5fb6457580fcba1dcd3e6737aa7f522336890b0536506R68

            tusefomal Ferran Recio
            monidu Nicolas Dunand
            Carlos Escobedo Carlos Escobedo
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Gladys Basiana Gladys Basiana
            Votes:
            15 Vote for this issue
            Watchers:
            26 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 7 hours, 5 minutes
                7h 5m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.