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

Add CFG option to treat debugging() calls as errors

XMLWordPrintable

    • MOODLE_404_STABLE
    • MOODLE_404_STABLE
    • MDL-80206-main
    • Hide
      1. Put Moodle into Dev mode and update composer dependencies:

        mdk run dev
        php composer.phar install
        

      2. Open lib/classes/userfeedback.php in your preferred editor
      3. Locate the can_give_feedback() method and add into the body of the method:

        debugging('This method is deprecated!');
        

      4. Log into Moodle and navigate to the Dashboard
        1. Confirm that you see a pretty Whoops page
      5. Remove the vendor directory

        rm -rf vendor
        

      6. Refresh the page
        1. Confirm that you get a regular text-based debugging mesage as a part of the page
      7. Open config.php in your preferred editor
      8. Somewhere before the require_once line, add:

        $CFG->debug_developer_debugging_as_error = true;
        

      9. Refresh the page
        1. Confirm that you get some kind of notice
          Note: If you are using xdebug, it will be butt ugly and Orange
      10. Change the setting to false:

        $CFG->debug_developer_debugging_as_error = false;
        

      11. Refresh the page
        1. Confirm that you get a debugging notice with stack trace
      12. Install composer dependencies again;

        php composer.phar install
        

      13. Refresh the page
        1. Confirm that you get a debugging notice with stack trace (not whoops)
      14. Unset the setting (remove it)
      15. Refresh the page
        1. Confirm that you get a pretty Whoops page
      16. Run mdk undev:

        mdk run undev
        

      17. Refresh the page
        1. Confirm you got nothing
      Show
      Put Moodle into Dev mode and update composer dependencies: mdk run dev php composer.phar install Open lib/classes/userfeedback.php in your preferred editor Locate the can_give_feedback() method and add into the body of the method: debugging('This method is deprecated!'); Log into Moodle and navigate to the Dashboard Confirm that you see a pretty Whoops page Remove the vendor directory rm -rf vendor Refresh the page Confirm that you get a regular text-based debugging mesage as a part of the page Open config.php in your preferred editor Somewhere before the require_once line, add: $CFG->debug_developer_debugging_as_error = true; Refresh the page Confirm that you get some kind of notice Note: If you are using xdebug, it will be butt ugly and Orange Change the setting to false: $CFG->debug_developer_debugging_as_error = false; Refresh the page Confirm that you get a debugging notice with stack trace Install composer dependencies again; php composer.phar install Refresh the page Confirm that you get a debugging notice with stack trace (not whoops) Unset the setting (remove it) Refresh the page Confirm that you get a pretty Whoops page Run mdk undev: mdk run undev Refresh the page Confirm you got nothing

      So often it can be easy to miss a call to debugging() in the output. That may be because it's halfway down a page, or underneath a navbar.

      Now that we have added Whoops support, I wonder whether it is also worth having a new option to have calls to debugging() throw a fatal error.

      This will surface them so they are not possible to miss and, when used with whoops, are easier to debug.

      I would almost go as far as saying that it should be on by default when whoops is available.

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Michael Hawkins Michael Hawkins
            Safat Shahin Safat Shahin
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            1 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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