mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-70357 cron: Catch Throwables not just Exceptions when running tasks
Starting from PHP 7, most language errors throw Error exceptions. We want to deal with those equally as with any other exception so we need to catch all Throwables here.
This commit is contained in:
parent
c8a6134c8c
commit
afb99e900b
1 changed files with 3 additions and 3 deletions
|
@ -182,7 +182,7 @@ function cron_run_adhoc_tasks(int $timenow, $keepalive = 0, $checklimits = true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$task = \core\task\manager::get_next_adhoc_task(time(), $checklimits);
|
$task = \core\task\manager::get_next_adhoc_task(time(), $checklimits);
|
||||||
} catch (Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
if ($adhoclock) {
|
if ($adhoclock) {
|
||||||
// Release the adhoc task runner lock.
|
// Release the adhoc task runner lock.
|
||||||
$adhoclock->release();
|
$adhoclock->release();
|
||||||
|
@ -260,7 +260,7 @@ function cron_run_inner_scheduled_task(\core\task\task_base $task) {
|
||||||
}
|
}
|
||||||
mtrace('Scheduled task complete: ' . $fullname);
|
mtrace('Scheduled task complete: ' . $fullname);
|
||||||
\core\task\manager::scheduled_task_complete($task);
|
\core\task\manager::scheduled_task_complete($task);
|
||||||
} catch (Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
if ($DB && $DB->is_transaction_started()) {
|
if ($DB && $DB->is_transaction_started()) {
|
||||||
error_log('Database transaction aborted automatically in ' . get_class($task));
|
error_log('Database transaction aborted automatically in ' . get_class($task));
|
||||||
$DB->force_transaction_rollback();
|
$DB->force_transaction_rollback();
|
||||||
|
@ -348,7 +348,7 @@ function cron_run_inner_adhoc_task(\core\task\adhoc_task $task) {
|
||||||
}
|
}
|
||||||
mtrace("Adhoc task complete: " . get_class($task));
|
mtrace("Adhoc task complete: " . get_class($task));
|
||||||
\core\task\manager::adhoc_task_complete($task);
|
\core\task\manager::adhoc_task_complete($task);
|
||||||
} catch (Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
if ($DB && $DB->is_transaction_started()) {
|
if ($DB && $DB->is_transaction_started()) {
|
||||||
error_log('Database transaction aborted automatically in ' . get_class($task));
|
error_log('Database transaction aborted automatically in ' . get_class($task));
|
||||||
$DB->force_transaction_rollback();
|
$DB->force_transaction_rollback();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue