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

assign_refresh_events() might not refresh other assignments from other courses

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.5, 3.2.2
    • Fix Version/s: 3.1.6, 3.2.3
    • Component/s: Assignment
    • Labels:
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Pull Master Branch:
      MDL-58463-master

      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

              Assignee:
              jpataleta Jun Pataleta
              Reporter:
              jpataleta Jun Pataleta
              Peer reviewer:
              Mark Nelson
              Integrator:
              Dan Poltawski
              Tester:
              Ankit Agarwal
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                8/May/17