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

Coding error on using renderer in _get_coursemodule_info()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not a bug
    • Affects Version/s: 2.4.5, 2.5.1
    • Fix Version/s: None
    • Component/s: Course, Libraries
    • Labels:
    • Testing Instructions:
      Hide
      • Create a mod plugin of type resource
      • In the modname_get_coursemodule_info() function, use $PAGE->get_renderer() to access a renderer
      • Add two instances of your module to a course
      • Delete them both using Ajax
      • View the Ajax response and ensure there are no errors returned
      • Refresh page and ensure that both are deleted
      Show
      Create a mod plugin of type resource In the modname_get_coursemodule_info() function, use $PAGE->get_renderer() to access a renderer Add two instances of your module to a course Delete them both using Ajax View the Ajax response and ensure there are no errors returned Refresh page and ensure that both are deleted
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull Master Branch:

      Description

      If a renderer is used in a module's modname_get_coursemodule_info() function, a coding error is thrown on attempting to delete a second course module from the same page without refreshing.

      To reproduce:

      • Create a mod plugin of type resource
      • In the modname_get_coursemodule_info() function, use $PAGE->get_renderer() to access a renderer
      • Add two instances of your module to a course
      • Delete the first instance (this works fine)
      • Delete the second instance and view the result of the Ajax request to /course/rest.php
      • You should see an error like this:

      Coding problem: $PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context(). The page may not display correctly as a result

      line 450 of \lib\pagelib.php: call to debugging()
      line 1425 of \lib\pagelib.php: call to moodle_page->magic_get_context()
      line 635 of \lib\pagelib.php: call to moodle_page->initialise_theme_and_output()
      line 754 of \lib\pagelib.php: call to moodle_page->magic_get_theme()
      line 154 of \mod\liblinks\lib.php: call to moodle_page->get_renderer()
      line 1142 of \course\lib.php: call to liblinks_get_coursemodule_info()
      line 1429 of \lib\modinfolib.php: call to get_array_of_activities()
      line 249 of \lib\modinfolib.php: call to rebuild_course_cache()
      line 1359 of \lib\modinfolib.php: call to course_modinfo->__construct()
      line 2789 of \lib\moodlelib.php: call to get_fast_modinfo()
      line 56 of \course\rest.php: call to require_login()

      Note that this happens on deleting any kind of course module on the page. For example, you can add an instance of your module to a page along with two labels, and the above behaviour will happen on attempting to delete the second label.

        Attachments

          Activity

            People

            Assignee:
            maherne Michael Aherne
            Reporter:
            maherne Michael Aherne
            Peer reviewer:
            Marina Glancy
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: