From 23af18182a64ecf82390112a58b695e7f277b5cc Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 4 Aug 2020 16:19:09 -0400 Subject: [PATCH] Show cron warning on Scheduled Jobs admin page --- CRM/Admin/Page/Job.php | 11 +++++++++++ CRM/Utils/Check/Component/Env.php | 2 +- CRM/Utils/REST.php | 2 +- CRM/Utils/System.php | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CRM/Admin/Page/Job.php b/CRM/Admin/Page/Job.php index e8ba06d9d5..2164d2b7ce 100644 --- a/CRM/Admin/Page/Job.php +++ b/CRM/Admin/Page/Job.php @@ -142,6 +142,17 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { if (CRM_Core_Config::environment() != 'Production') { CRM_Core_Session::setStatus(ts('Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter.'), ts("Non-production Environment"), "warning", array('expires' => 0)); } + else { + $cronError = Civi\Api4\System::check(FALSE) + ->addWhere('name', '=', 'checkLastCron') + ->addWhere('severity_id', '>', 1) + ->setIncludeDisabled(TRUE) + ->execute() + ->first(); + if ($cronError) { + CRM_Core_Session::setStatus($cronError['message'], $cronError['title'], 'alert', ['expires' => 0]); + } + } $sj = new CRM_Core_JobManager(); $rows = $temp = []; diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index 24b54a9473..f3a494ab95 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -325,7 +325,7 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component { // After 1 day (86400 seconds) increase the error level $level = ($lastCron > $now - 86400) ? \Psr\Log\LogLevel::WARNING : \Psr\Log\LogLevel::ERROR; } - $msg .= '

' . ts('To enable scheduling support, please set up the cron job.') . + $msg .= '

' . ts('A cron job is required to execute scheduled jobs automatically.') . '
' . CRM_Utils_System::docURL2('sysadmin/setup/jobs/') . '

'; } diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index 5b436c0f20..03c7c26d1c 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -212,7 +212,7 @@ class CRM_Utils_REST { // interface can be disabled in more change to the configuration file. // first check for civicrm site key if (!CRM_Utils_System::authenticateKey(FALSE)) { - $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", TRUE, NULL, NULL, NULL, "wiki"); + $docLink = CRM_Utils_System::docURL2('sysadmin/setup/jobs', TRUE); $key = $requestParams['key'] ?? NULL; if (empty($key)) { return self::error("FATAL: mandatory param 'key' missing. More info at: " . $docLink); diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index debc640b5b..cedef4ca0d 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -600,7 +600,7 @@ class CRM_Utils_System { // also make sure the key is sent and is valid $key = trim(CRM_Utils_Array::value('key', $_REQUEST)); - $docAdd = "More info at:" . CRM_Utils_System::docURL2("Managing Scheduled Jobs", TRUE, NULL, NULL, NULL, "wiki"); + $docAdd = "More info at: " . CRM_Utils_System::docURL2('sysadmin/setup/jobs', TRUE); if (!$key) { return self::authenticateAbort( -- 2.25.1