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

MDL-57103 tries to use $PAGE before it has been initialised

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.3.5, 3.4.2
    • 3.3.4, 3.4.1
    • Libraries
    • MOODLE_33_STABLE, MOODLE_34_STABLE
    • MOODLE_33_STABLE, MOODLE_34_STABLE
    • Hide
      1. Set Debugging to All
      2. Tail your web sever error log
      3. Generate a fake error:

        diff --git a/lib/ajax/service.php b/lib/ajax/service.php
        index 3298c0e7a7..044903137e 100644
        --- a/lib/ajax/service.php
        +++ b/lib/ajax/service.php
        @@ -41,6 +40,7 @@ if ($requests === null) {
             $lasterror = json_last_error_msg();
             throw new coding_exception('Invalid json in request: ' . $lasterror);
         }
        +throw new coding_exception('oh no!');
         $responses = array();
         
         // Defines the external settings required for Ajax processing.
        

      4. Visit the Dashboard
        1. Confirm that the debugging log showed errors for the oh no! response
        2. Confirm that there were no debugging notes in the logs for anything resembling the following:

          [Mon Feb 12 15:16:07.577174 2018] [:error] [pid 13804] [client 172.20.254.187:63615] 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 \n* line 493 of /lib/pagelib.php: call to debugging()\n* line 1544 of /lib/pagelib.php: call to moodle_page->magic_get_context()\n* line 677 of /lib/pagelib.php: call to moodle_page->initialise_theme_and_output()\n* line 864 of /lib/pagelib.php: call to moodle_page->magic_get_theme()\n* line 370 of /lib/setuplib.php: call to moodle_page->get_renderer()\n* line ? of unknownfile: call to default_exception_handler()\n, referer: http://boysenberry.local/im/my/
          

      Show
      Set Debugging to All Tail your web sever error log Generate a fake error: diff --git a/lib/ajax/service.php b/lib/ajax/service.php index 3298c0e7a7..044903137e 100644 --- a/lib/ajax/service.php +++ b/lib/ajax/service.php @@ -41,6 +40,7 @@ if ($requests === null) { $lasterror = json_last_error_msg(); throw new coding_exception('Invalid json in request: ' . $lasterror); } +throw new coding_exception('oh no!'); $responses = array(); // Defines the external settings required for Ajax processing. Visit the Dashboard Confirm that the debugging log showed errors for the oh no! response Confirm that there were no debugging notes in the logs for anything resembling the following: [Mon Feb 12 15:16:07.577174 2018] [:error] [pid 13804] [client 172.20.254.187:63615] 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 \n* line 493 of /lib/pagelib.php: call to debugging()\n* line 1544 of /lib/pagelib.php: call to moodle_page->magic_get_context()\n* line 677 of /lib/pagelib.php: call to moodle_page->initialise_theme_and_output()\n* line 864 of /lib/pagelib.php: call to moodle_page->magic_get_theme()\n* line 370 of /lib/setuplib.php: call to moodle_page->get_renderer()\n* line ? of unknownfile: call to default_exception_handler()\n, referer: http://boysenberry.local/im/my/

      PHP logs are full of

      [05-Feb-2018 20:07:00 Europe/London] 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 493 of /lib/pagelib.php: call to debugging()
      line 1587 of /lib/pagelib.php: call to moodle_page->magic_get_context()
      line 677 of /lib/pagelib.php: call to moodle_page->initialise_theme_and_output()
      line 864 of /lib/pagelib.php: call to moodle_page->magic_get_theme()
      line 390 of /lib/setuplib.php: call to moodle_page->get_renderer()
      line ? of unknownfile: call to default_exception_handler()

      This is because MDL-57103 uses global $PAGE in a place way before it has been initialised.

            timhunt Tim Hunt
            timhunt Tim Hunt
            Jake Dallimore Jake Dallimore
            Andrew Lyons Andrew Lyons
            Adrian Greeve Adrian Greeve
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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