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

Cronlib catches Exceptions instead of Throwables

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.9.4, 3.10.1
    • 3.10
    • Tasks
    • MOODLE_310_STABLE
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • MDL-70357-master-cronlibthrowables
    • Hide

      The idea of testing is to modify the code so that it throws an Error exception and then confirm that we only see a failed task without any further uncaught exceptions.

      1. Modify the source code of the file mod/workshop/allocation/scheduled/classes/task/cron_task.php:
        • Around the line 59 change the name of the method "get_records_sql()" to something non-existing such as "muhahaha_get_records_sql()"
      2. Run the task:

        $ sudo -u apache php admin/cli/scheduled_task.php --execute='\workshopallocation_scheduled\task\cron_task'
        

      3. TEST Check that the output contains something like "Scheduled task failed - Call to undefined method"
      4. TEST Confirm there is no other exception handling output such as "Default exception handler: Exception", no error related to database locking etc.
      Show
      The idea of testing is to modify the code so that it throws an Error exception and then confirm that we only see a failed task without any further uncaught exceptions. Modify the source code of the file mod/workshop/allocation/scheduled/classes/task/cron_task.php: Around the line 59 change the name of the method "get_records_sql()" to something non-existing such as "muhahaha_get_records_sql()" Run the task: $ sudo -u apache php admin/cli/scheduled_task.php --execute='\workshopallocation_scheduled\task\cron_task' TEST Check that the output contains something like "Scheduled task failed - Call to undefined method" TEST Confirm there is no other exception handling output such as "Default exception handler: Exception", no error related to database locking etc.

      As was noticed in MDLSITE-6261, PHP errors are not properly handled by the scheduled and adhoc tasks runner.

      If there is a problem in the code that leads to throwing "Error" instance, e.g. as in

      ...
      * line 110 of /course/classes/search/customfield.php: Error thrown
      ...
      

      this is not caught and leads to further errors related to locking.

            mudrd8mz David Mudrák (@mudrd8mz)
            mudrd8mz David Mudrák (@mudrd8mz)
            Sam Marshall Sam Marshall
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 30 minutes
                1h 30m

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