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

URL resource causes exception in course modinfo cache rebuild

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.7.2
    • 3.7.4, 3.8.1
    • Other
    • MOODLE_37_STABLE
    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • MDL-66936-master
    • Hide
      1. Add a URL resource to a course:
        1. External URL: https://example.org/
        2. URL variables: foo = Course id
      2. With AJAX course editing enabled, move the URL resource right. (This invalidates the course modinfo cache.)
      3. Move the URL resource right again. You should experience no errors.
      Show
      Add a URL resource to a course: External URL: https://example.org/ URL variables: foo = Course id With AJAX course editing enabled, move the URL resource right. (This invalidates the course modinfo cache.) Move the URL resource right again. You should experience no errors.

    Description

      A URL resource with URL variables configured will cause a coding exception when the course modinfo cache is rebuilt outside a page view, like by AJAX call.

      To reproduce:

      1. Add a URL resource to a course:
        1. External URL: https://example.org/
        2. URL variables: foo = Course id
      2. With AJAX course editing enabled, move the URL resource right. (This invalidates the course modinfo cache.)
      3. Move the URL resource right again. Observe the error message:

          Coding error detected, it must be fixed by a programmer: $PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context()
          Error code: codingerror
           * line 498 of /lib/pagelib.php: coding_exception thrown
           * line 830 of /lib/pagelib.php: call to moodle_page->magic_get_context()
           * line 1456 of /lib/weblib.php: call to moodle_page->__get()
           * line 463 of /mod/url/locallib.php: call to format_string()
           * line 109 of /mod/url/locallib.php: call to url_get_variable_values()
           * line 247 of /mod/url/lib.php: call to url_get_full_url()
           * line 466 of /course/lib.php: call to url_get_coursemodule_info()
           * line 670 of /lib/modinfolib.php: call to get_array_of_activities()
           * line 462 of /lib/modinfolib.php: call to course_modinfo::inner_build_course_cache()
           * line 417 of /lib/modinfolib.php: call to course_modinfo->__construct()
           * line 2168 of /lib/modinfolib.php: call to course_modinfo::instance()
           * line 2242 of /lib/modinfolib.php: call to get_fast_modinfo()
           * line 3494 of /course/externallib.php: call to get_course_and_cm_from_cmid()
           * line 244 of /lib/externallib.php: call to core_course_external::edit_module()
           * line 79 of /lib/ajax/service.php: call to external_api::call_external_function()
      

      Attachments

        Issue Links

          Activity

            People

              jonof Jonathon Fowler
              jonof Jonathon Fowler
              Marina Glancy Marina Glancy
              Jake Dallimore Jake Dallimore
              Janelle Barcega Janelle Barcega
              Adrian Greeve, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                13/Jan/20

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 16 minutes
                  3h 16m