diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index c1d7b767944f..3ee6ef1ec148 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -688,6 +688,54 @@ public function checkExtensions() { return $messages; } + /** + * @return CRM_Utils_Check_Message[] + */ + public function checkScheduledJobLogErrors() { + $jobs = civicrm_api3('Job', 'get', [ + 'sequential' => 1, + 'return' => ["id", "name", "last_run"], + 'is_active' => 1, + 'options' => ['limit' => 0], + ]); + $html = ''; + foreach ($jobs['values'] as $job) { + $lastExecutionMessage = civicrm_api3('JobLog', 'get', [ + 'sequential' => 1, + 'return' => ["description"], + 'job_id' => $job['id'], + 'options' => ['sort' => "id desc", 'limit' => 1], + ])['values'][0]['description'] ?? NULL; + if (!empty($lastExecutionMessage) && strpos($lastExecutionMessage, 'Failure') !== FALSE) { + $viewLogURL = CRM_Utils_System::url('civicrm/admin/joblog', "jid={$job['id']}&reset=1"); + $html .= '
' . ts('The following scheduled jobs failed on the last run:') . '
+' . ts('Job') . ' | ' . ts('Message') . ' | ' . ts('Last Run') . ' | + |
---|