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

Ensure default_exception_handler works ok @ early stages

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 3.8
    • 3.6.4, 3.7, 3.8
    • General, Installation
    • MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • MOODLE_38_STABLE
    • Hide
      Prerequisites

      As far as we are going to verify some really early errors and they happen BEFORE any access to database, it's important to ensure that the following settings are defined in the config.php file, before the require_once(... line:

      $CFG->debug = E_ALL | E_STRICT;
      $CFG->debugdisplay = true;

      With the patch not applied (or reverted)
      1. Delete mod/assign/db/subplugins.json
      2. Go to the site main page.
      3. Verify that you get a blank page.
      4. Verify that in the webserver error log you get a PHP Fatal error related to Call to undefined function current_language().
      With the patch applied
      1. Delete mod/assign/db/subplugins.json
      2. Go to the site main page.
      3. Verify that now you get a exception in the web page.
      4. Verify that the error is not anymore about current_language(), get_docs_url(), s() or get_performance_info()).
      5. Verify that the error is the real one, aka, it says:

        Debug info: 
        Error code: generalexceptionmessage
        $a contents: Call to undefined function debugging()
        Stack trace:
        line 540 of /lib/classes/component.php: Error thrown
        line 471 of /lib/classes/component.php: call to core_component::fetch_subtypes()
        line 383 of /lib/classes/component.php: call to core_component::fetch_plugintypes()
        ...
        ...
        

      Note: Don't worry about the error above, it's being fixed @ MDL-65995

      Show
      Prerequisites As far as we are going to verify some really early errors and they happen BEFORE any access to database, it's important to ensure that the following settings are defined in the config.php file, before the require_once(... line: $CFG->debug = E_ALL | E_STRICT; $CFG->debugdisplay = true; With the patch not applied (or reverted) Delete mod/assign/db/subplugins.json Go to the site main page. Verify that you get a blank page. Verify that in the webserver error log you get a PHP Fatal error related to Call to undefined function current_language() . With the patch applied Delete mod/assign/db/subplugins.json Go to the site main page. Verify that now you get a exception in the web page. Verify that the error is not anymore about current_language() , get_docs_url() , s() or get_performance_info() ). Verify that the error is the real one, aka, it says: Debug info: Error code: generalexceptionmessage $a contents: Call to undefined function debugging() Stack trace: line 540 of /lib/classes/component.php: Error thrown line 471 of /lib/classes/component.php: call to core_component::fetch_subtypes() line 383 of /lib/classes/component.php: call to core_component::fetch_plugintypes() ... ... Note: Don't worry about the error above, it's being fixed @ MDL-65995

      When looking for some "blank page" recent problems (see MDL-65995), happening really early in the bootstrap/warmup moodle code... it was detected that the default_exception_handler uses some stuff that is not guaranteed to be available at the moment the exception happens.

      This is the list of errors that we detected:

      [21-Jun-2019 08:09:41 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function current_language() in /Applications/MAMP/htdocs/master/lib/setuplib.php:688
      Stack trace:
      #0 /Applications/MAMP/htdocs/master/lib/setuplib.php(572): get_docs_url()
      #1 /Applications/MAMP/htdocs/master/lib/setuplib.php(363): get_exception_info(Object(Error))
      #2 [internal function]: default_exception_handler(Object(Error))
      #3 {main}
        thrown in /Applications/MAMP/htdocs/master/lib/setuplib.php on line 688
      

      Once we commented out get_docs_url() we got:

      [21-Jun-2019 08:38:04 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function debugging() in /Applications/MAMP/htdocs/master/lib/setuplib.php:365
      Stack trace:
      #0 [internal function]: default_exception_handler(Object(Error))
      #1 {main}
        thrown in /Applications/MAMP/htdocs/master/lib/setuplib.php on line 365
      

      And, once we replaced that debugging(), we finally were able to see the real error happening (that was MDL-65995).

      So this issue is about to guarantee that when a error happens early in Moodle bootstrap/warmup and the default_exception_handler is called... it's immune to any dependency that could not be available yet.

      Ciao

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Andrew Lyons Andrew Lyons
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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