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

Course edit passes invalid course object to require login

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 2.5.3
    • Course
    • MOODLE_25_STABLE

      In course/edit.php, there is some code that call require_login() in the following way:

      $course = course_get_format($id)->get_course();
      require_login($course);
      

      At first, this looks harmless, but it actually causes a really odd edge case. Basically the above code populates the $COURSE global with the course format options.

      At first, this doesn't really harm anything, until course caches are cleared. Once cleared, the format_base::get_course calls get_course() which reads the course from the $COURSE global. Then it reports that the course format options are not valid because the appear to be the same as a field in the course table.

      I'm not sure if this can be replicated with stock Moodle, but we have a customization listening to the course_updated event which is fired after caches are cleared and the customization then uses the format_base API.

      So, my two suggested solutions are:

      1. Ensure that when require_login() is called, it is not using a $course object from format_base::get_course
      2. Ensure that when $COURSE global is set, it doesn't include course format options.

      The latter is probably more appealing since 3rd party code could be doing this. Of course, other solutions are probably out there!

            Unassigned Unassigned
            bushido Mark Nielsen (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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