From f016dc2302c45deaa9449dc3c717bc58f7b71484 Mon Sep 17 00:00:00 2001 From: Brendan Heywood Date: Thu, 6 Feb 2025 09:25:38 +1100 Subject: [PATCH] MDL-84438 task: Ignore tasks which don't have valid classes --- lib/classes/task/manager.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/classes/task/manager.php b/lib/classes/task/manager.php index 26625d20485..1ba81e9eb0f 100644 --- a/lib/classes/task/manager.php +++ b/lib/classes/task/manager.php @@ -646,15 +646,17 @@ class manager { foreach ($records as $record) { $task = self::scheduled_task_from_record($record); + // Safety check in case the task in the DB does not match a real class (maybe something was uninstalled). + if (!$task) { + continue; + } + // Tasks belonging to deprecated plugin types are excluded. if (self::task_component_is_deprecated($task)) { continue; } - // Safety check in case the task in the DB does not match a real class (maybe something was uninstalled). - if ($task) { - $tasks[] = $task; - } + $tasks[] = $task; } return $tasks;