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

mod_assign_generator does not clear course cache somewhere

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.5.2
    • 2.5.1
    • Assignment

      While working on MDL-34397 I replaced the cache and one of the unit tests started to fail. So I figured out that coruse cache is not reset properly in mod_assign_generator. Probably because of reverse order of actions - first module is added to section and then module is created.

      To reproduce add the following to the mod_assign_lib_testcase :

          public function test_assign_gen1() {
              global $DB;
              $this->create_instance();
              $record = $DB->get_record('course', array('id' => $this->course->id));
              // Make sure the course cache is cleared
              $this->assertEmpty($record->modinfo);
              // Rebuild modinfo and make sure that module is present
              $modinfo = get_fast_modinfo($this->course->id);
              $this->assertNotEmpty($modinfo->cms);
          }
      

      It works fine. BUT both assertions here fail:

          public function test_assign_gen2() {
              global $DB;
              $this->create_instance(array('duedate'=>time()));
              $record = $DB->get_record('course', array('id' => $this->course->id));
              // This fails, course cache was not cleared (commented out to show the next failure):
              // $this->assertEmpty($record->modinfo);
              // This also fails, because the course cache was generated before the module was added:
              $modinfo = get_fast_modinfo($this->course->id);
              $this->assertNotEmpty($modinfo->cms);
          }
      

      Which means that after calling the generator with non-empty duedate the course cache was not properly cleared.

            marina Marina Glancy
            marina Marina Glancy
            Damyon Wiese Damyon Wiese
            Sam Hemelryk Sam Hemelryk
            Andrew Davis Andrew Davis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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