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

Cronlib catches Exceptions instead of Throwables

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.10
    • Fix Version/s: 3.9.4, 3.10.1
    • Component/s: Tasks
    • Labels:
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_310_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE, MOODLE_39_STABLE
    • Pull from Repository:
    • Pull 3.9 Branch:
      MDL-70357-39-cronlibthrowables
    • Pull 3.10 Branch:
      MDL-70357-310-cronlibthrowables
    • Pull 3.11 Branch:
      MDL-70357-311-cronlibthrowables
    • Pull Master Branch:
      MDL-70357-master-cronlibthrowables

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            mudrd8mz David Mudrák (@mudrd8mz)
            Reporter:
            mudrd8mz David Mudrák (@mudrd8mz)
            Peer reviewer:
            Sam Marshall
            Integrator:
            Sara Arjona (@sarjona)
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              18/Jan/21

                Time Tracking

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