Show cron warning on Scheduled Jobs admin page
authorColeman Watts <coleman@civicrm.org>
Tue, 4 Aug 2020 20:19:09 +0000 (16:19 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 4 Aug 2020 20:19:09 +0000 (16:19 -0400)
CRM/Admin/Page/Job.php
CRM/Utils/Check/Component/Env.php
CRM/Utils/REST.php
CRM/Utils/System.php

index e8ba06d9d549feddc6523d1bfb01834c7c1a3b4c..2164d2b7cefa57fd7c6531b9b6243d2933abf7cd 100644 (file)
@@ -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 = [];
index 24b54a94732d713dca8cc45afcb206526e856720..f3a494ab95131c23f3490d7017c1ab6461a9f2ce 100644 (file)
@@ -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 .= '<p>' . ts('To enable scheduling support, please set up the cron job.') .
+      $msg .= '<p>' . ts('A cron job is required to execute scheduled jobs automatically.') .
        '<br />' . CRM_Utils_System::docURL2('sysadmin/setup/jobs/') . '</p>';
     }
 
index 5b436c0f2016a983ea878377f1e9166390adb349..03c7c26d1c0db6530ec04308b7c4aa298b621934 100644 (file)
@@ -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);
index debc640b5b38ca97d4259963ad97a67c9fe0f62d..cedef4ca0d458ca83af785ebf097b81633d5dc58 100644 (file)
@@ -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(