Merge pull request #23509 from eileenmcnaughton/import_except
[civicrm-core.git] / CRM / Admin / Page / Job.php
index e8ba06d9d549feddc6523d1bfb01834c7c1a3b4c..a521989ae254f3648d73169fb18df3200aa84dea 100644 (file)
@@ -117,6 +117,9 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String',
       $this, FALSE, 0
     );
+    $this->_context = CRM_Utils_Request::retrieve('context', 'String',
+      $this, FALSE, 0
+    );
 
     if (($this->_action & CRM_Core_Action::COPY) && (!empty($this->_id))) {
       try {
@@ -142,15 +145,26 @@ 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 = [];
+    $rows = [];
     foreach ($sj->jobs as $job) {
       $action = array_sum(array_keys($this->links()));
 
       // update enable/disable links.
       // CRM-9868- remove enable action for jobs that should never be run automatically via execute action or runjobs url
-      if ($job->api_action == 'process_membership_reminder_date' || $job->api_action == 'update_greeting') {
+      if ($job->api_action === 'process_membership_reminder_date' || $job->api_action === 'update_greeting') {
         $action -= CRM_Core_Action::ENABLE;
         $action -= CRM_Core_Action::DISABLE;
       }
@@ -161,8 +175,8 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic {
         $action -= CRM_Core_Action::DISABLE;
       }
 
-      $job->action = CRM_Core_Action::formLink(self::links(), $action,
-        array('id' => $job->id),
+      $job->action = CRM_Core_Action::formLink($this->links(), $action,
+        ['id' => $job->id],
         ts('more'),
         FALSE,
         'job.manage.action',