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

mod_assign_generator does not clear course cache somewhere

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.1
    • Fix Version/s: 2.5.2
    • Component/s: Assignment
    • Labels:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                marina Marina Glancy
                Reporter:
                marina Marina Glancy
                Peer reviewer:
                Damyon Wiese
                Integrator:
                Sam Hemelryk
                Tester:
                Andrew Davis
                Participants:
                Component watchers:
                Damyon Wiese, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Sep/13