[Smarty variables] Remove issets from scheduled job screen
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 29 Nov 2021 23:36:49 +0000 (12:36 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 29 Nov 2021 23:37:10 +0000 (12:37 +1300)
CRM/Admin/Page/Job.php
CRM/Core/JobManager.php
templates/CRM/Admin/Page/Job.tpl
tests/phpunit/CRM/Core/FormTest.php

index 5a8d30767c570fcbc86885b991cd37f9abb7dfaf..a521989ae254f3648d73169fb18df3200aa84dea 100644 (file)
@@ -158,13 +158,13 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic {
     }
 
     $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;
       }
@@ -175,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',
index d30646262e9f2f9dc99086c8d1c05187cee49a1d..ad170f08cbb3564823c264e8f82caaf6f074235e 100644 (file)
@@ -152,14 +152,14 @@ class CRM_Core_JobManager {
    * @return array
    *   ($id => CRM_Core_ScheduledJob)
    */
-  private function _getJobs() {
+  private function _getJobs(): array {
     $jobs = [];
     $dao = new CRM_Core_DAO_Job();
     $dao->orderBy('name');
     $dao->domain_id = CRM_Core_Config::domainID();
     $dao->find();
     while ($dao->fetch()) {
-      $temp = [];
+      $temp = ['class' => NULL, 'parameters' => NULL, 'last_run' => NULL];
       CRM_Core_DAO::storeValues($dao, $temp);
       $jobs[$dao->id] = new CRM_Core_ScheduledJob($temp);
     }
index 3a999252cb624485220a522bbf6aa9870cd9ca18..2738a86b94f33031bdb68587b7a753853cd605f6 100644 (file)
             <th ></th>
         </tr>
         {foreach from=$rows item=row}
-        <tr id="job-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"} {if !empty($row.class)}{$row.class}{/if}{if NOT $row.is_active} disabled{/if}">
+        <tr id="job-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"} {$row.class}{if NOT $row.is_active} disabled{/if}">
             <td class="crm-job-name"><strong><span data-field="name">{$row.name}</span></strong> ({$row.run_frequency})<br/>
                 {$row.description}<br />
                 {ts}API Entity:{/ts} {$row.api_entity}<br/>
                 {ts}API Action:{/ts} <strong>{$row.api_action}</strong><br/>
             </td>
-            <td class="crm-job-name">{if isset($row.parameters)}{if $row.parameters eq null}<em>{ts}no parameters{/ts}</em>{else}<pre>{$row.parameters}</pre>{/if}{/if}</td>
-            <td class="crm-job-name">{if isset($row.last_run)}{if $row.last_run eq null}never{else}{$row.last_run|crmDate:$config->dateformatDatetime}{/if}{/if}</td>
+            <td class="crm-job-name">{if $row.parameters eq null}<em>{ts}no parameters{/ts}</em>{else}<pre>{$row.parameters}</pre>{/if}</td>
+            <td class="crm-job-name">{if $row.last_run eq null}never{else}{$row.last_run|crmDate:$config->dateformatDatetime}{/if}</td>
             <td id="row_{$row.id}_status" class="crm-job-is_active">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
           <td>{$row.action|replace:'xx':$row.id}</td>
         </tr>
index 958efb1b1cc9a5a0742ad3b3ae312d8ac9218d96..54b785069841be5d16d6a6b8eb66ac0176cdb445 100644 (file)
@@ -39,7 +39,7 @@ class CRM_Core_FormTest extends CiviUnitTestCase {
   }
 
   /**
-   * Dataprovider for testOpeningForms().
+   * Data provider for testOpeningForms().
    * TODO: Add more forms!
    *
    * @return array
@@ -65,6 +65,9 @@ class CRM_Core_FormTest extends CiviUnitTestCase {
       'Message Templates' => [
         'civicrm/admin/messageTemplates?reset=1',
       ],
+      'Scheduled Jobs' => [
+        'civicrm/admin/job?reset=1',
+      ],
     ];
   }