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

assign_refresh_events() might not refresh other assignments from other courses

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1.5, 3.2.2
    • 3.1.6, 3.2.3
    • Assignment
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MDL-58463-master
    • Hide
      1. Run PHP Unit for mod_assign_lib_testcase:

        vendor/bin/phpunit mod_assign_lib_testcase mod/assign/tests/lib_test.php
        

        (or if using MDK)

        mdk phpunit -r -u mod/assign/tests/lib_test.php
        

        • Confirm that there are no errors nor failures.
      Show
      Run PHP Unit for mod_assign_lib_testcase: vendor/bin/phpunit mod_assign_lib_testcase mod/assign/tests/lib_test.php (or if using MDK) mdk phpunit -r -u mod/assign/tests/lib_test.php Confirm that there are no errors nor failures.

    Description

      The following logic in assign_refresh_events() is wrong:

      if (!$courseid) {
          $courseid = $assign->course;
          if (!$course = $DB->get_record('course', array('id' => $courseid), '*')) {
              continue;
          }
      }
      

      In the case where the course ID parameter is not passed, then all assignment events from all courses should be refreshed. However, with the logic above, only the first course's assignments will be refreshed since for the other assignments in other courses, the expression

          if (!$cm = get_coursemodule_from_instance('assign', $assign->id, $courseid, false)) {
              continue;
          }
      

      will evaluate to true due to a non-existent course module due to the course ID not matching the assignment's course ID.

      Note: This only affects 32 and 31 since the fix for this issue is already being addressed in MDL-57607 on master. This issue has not been discovered since there was basically no use-case for 32 and 31 where a course ID of 0 is being passed.

      Attachments

        Issue Links

          Activity

            People

              jpataleta Jun Pataleta
              jpataleta Jun Pataleta
              Mark Nelson Mark Nelson
              Dan Poltawski Dan Poltawski
              Ankit Agarwal Ankit Agarwal
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                8/May/17