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

Revert exception throwing if page context is not set (MDL-53274)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • 3.1
    • Web Services
    • MOODLE_31_STABLE
    • MDL-53742-master
    • Hide
      1. Edit course/externallib.php and add the following at the start of search_courses.

        global $PAGE;
        $PAGE->context;
        

      2. Make sure the debugging level is set to developer
      3. Enable the Course meta link enrolment plugin
      4. Go to a course > Enrolment methods and ad a new instance of the Course meta link.
      5. Search for a course
      6. Confirm that you do not see any error
      Show
      Edit course/externallib.php and add the following at the start of search_courses . global $PAGE; $PAGE->context; Make sure the debugging level is set to developer Enable the Course meta link enrolment plugin Go to a course > Enrolment methods and ad a new instance of the Course meta link. Search for a course Confirm that you do not see any error

      This issue is now only about reverting MDL-53274


      Original description:
      Since MDL-53274, any Ajax/WS call that runs on a context that is not a course/module context may throw an exception, especially when dealing with renderers which is required for export_for_template. This is due to the PAGE->context not being set.

      I suggest that we always set the PAGE->context in validate_context, regardless of the contextlevel. Possibly simply by using require_login.

      If we don't, we will soon end-up with these, which are just the same thing but as a local hack:
      https://github.com/moodle/moodle/blob/master/tag/classes/external.php#L194

      (this one does not even call validate_context at all, but that is another problem)

      Edit: Actually, it is part of the problem as validate_context should always be called, and if not then I agree that an exception should be raised. So, if we combine validate_context + automatically setting PAGE->context to whichever context was validated, we're good to go. However that may not be easy as we can not change PAGE->context once set, and that will definitely happen in bulk Ajax calls.

            fred Frédéric Massart
            fred Frédéric Massart
            Ryan Wyllie Ryan Wyllie
            Votes:
            2 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

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