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

Throw exception (in developer mode) if page context is not set, otherwise it is not noticeable in AJAX calls

XMLWordPrintable

    • MOODLE_31_STABLE
    • MOODLE_31_STABLE
    • wip-MDL-53274-master
    • Hide

      this change can cause problems anywhere where we forgot to set page context in ajax requests. Hopefully all ajax features are covered by behat and will be discovered during automated testing.

      To test that error actually happens - comment out line $PAGE->set_context(null); in function get_tagindex in tag/classes/external.php
      Create more than 5 blog entries tagged with the same tag. Click on this tag name and try to navigate to the next page - it should throw an exception. Disable developer debugging mode and repeat - it should work (but leave errors in error.log)

      Ensure debugging is turned on and confirm that sending a message via the 'Message' button on a user's profile works.

      Show
      this change can cause problems anywhere where we forgot to set page context in ajax requests. Hopefully all ajax features are covered by behat and will be discovered during automated testing. To test that error actually happens - comment out line $PAGE->set_context(null); in function get_tagindex in tag/classes/external.php Create more than 5 blog entries tagged with the same tag. Click on this tag name and try to navigate to the next page - it should throw an exception. Disable developer debugging mode and repeat - it should work (but leave errors in error.log) Ensure debugging is turned on and confirm that sending a message via the 'Message' button on a user's profile works.

      If WS is called from AJAX request and it returns a templateable element, we need to call $PAGE->get_renderer(). If page context was not set it shows a debugging message. In AJAX requests debugging messages are muted.

      We keep missing such debugging messages (that pollute error.log), one of them in 3.0 (corrected in 3.0 branch of MDL-53254)

      Example:

      [Sat Feb 27 11:06:16.554674 2016] [:error] [pid 20755] [client 127.0.0.1:36868] Debugging: 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 in
      * line 453 of /lib/pagelib.php: call to debugging()
      * line 1525 of /lib/pagelib.php: call to moodle_page->magic_get_context()
      * line 637 of /lib/pagelib.php: call to moodle_page->initialise_theme_and_output()
      * line 812 of /lib/pagelib.php: call to moodle_page->magic_get_theme()
      * line 458 of /lib/external/externallib.php: call to moodle_page->get_renderer()
      * line ? of unknownfile: call to core_external::fetch_notifications()
      * line 83 of /lib/ajax/service.php: call to call_user_func_array()
      referer: http://localhost/mysql_master/blog/index.php?courseid=2
      

            marina Marina Glancy
            marina Marina Glancy
            Adrian Greeve Adrian Greeve
            Dan Poltawski Dan Poltawski
            cameron1729 cameron1729
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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