dev/core#1749 Fix missing parameter in link to logging detail
authoreileen <emcnaughton@wikimedia.org>
Mon, 1 Jun 2020 01:02:33 +0000 (13:02 +1200)
committereileen <emcnaughton@wikimedia.org>
Mon, 1 Jun 2020 01:02:35 +0000 (13:02 +1200)
https://lab.civicrm.org/dev/core/-/issues/1749

CRM/Logging/ReportSummary.php
CRM/Report/Form/Contact/LoggingSummary.php

index f7e93eeb24b332de5a41ab31dfe3f897030f0f3e..5ecdcac11bebff0136b4ed60fae0b8946134e07e 100644 (file)
  */
 
 /**
- *
- * @package CRM
- * @copyright CiviCRM LLC https://civicrm.org/licensing
- * $Id$
+ * Class CRM_Logging_ReportSummary
  */
 class CRM_Logging_ReportSummary extends CRM_Report_Form {
   protected $cid;
index c3ed3f542922d6c3febce46c75c5b03900accd13..8b347fb735b7ddbb58cdcb13389f249af1d799a2 100644 (file)
@@ -178,6 +178,9 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
    *
    * @param array $rows
    *   Rows generated by SQL, with an array for each row.
+   *
+   * @throws \CRM_Core_Exception
+   * @throws \CiviCRM_API3_Exception
    */
   public function alterDisplay(&$rows) {
     // cache for id → is_deleted mapping
@@ -206,9 +209,9 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
         $row['log_civicrm_entity_altered_contact_hover'] = ts("Go to contact summary");
         $entity = $this->getEntityValue($row['log_civicrm_entity_id'], $row['log_civicrm_entity_log_type'], $row['log_civicrm_entity_log_date']);
         if ($entity) {
-          $row['log_civicrm_entity_altered_contact'] = $row['log_civicrm_entity_altered_contact'] . " [{$entity}]";
+          $row['log_civicrm_entity_altered_contact'] .= " [{$entity}]";
         }
-        if ($entity == 'Contact Merged') {
+        if ($entity === 'Contact Merged') {
           // We're looking at a merge activity created against the surviving
           // contact record. There should be a single activity created against
           // the deleted contact record, with this activity as parent.
@@ -228,14 +231,14 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
 
       }
       $row['altered_by_contact_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_log_user_id']);
-      $row['altered_by_contact_display_name_hover'] = ts("Go to contact summary");
+      $row['altered_by_contact_display_name_hover'] = ts('Go to contact summary');
 
-      if ($row['log_civicrm_entity_is_deleted'] and 'Update' == CRM_Utils_Array::value('log_civicrm_entity_log_action', $row)) {
+      if ($row['log_civicrm_entity_is_deleted'] && 'Update' === $row['log_civicrm_entity_log_action']) {
         $row['log_civicrm_entity_log_action'] = ts('Delete (to trash)');
       }
 
-      if ('Contact' == CRM_Utils_Array::value('log_type', $this->_logTables[$row['log_civicrm_entity_log_type']]) &&
-        CRM_Utils_Array::value('log_civicrm_entity_log_action', $row) == ts('Insert')
+      if ('Contact' === ($this->_logTables[$row['log_civicrm_entity_log_type']]['log_type'] ?? NULL) &&
+        $row['log_civicrm_entity_log_action'] === ts('Insert')
       ) {
         $row['log_civicrm_entity_log_action'] = ts('Update');
       }
@@ -246,7 +249,7 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
       if ($newAction = $this->getEntityAction($row['log_civicrm_entity_id'],
         $row['log_civicrm_entity_log_conn_id'],
         $row['log_civicrm_entity_log_type'],
-        CRM_Utils_Array::value('log_civicrm_entity_log_action', $row))
+        ($row['log_civicrm_entity_log_action'] ?? NULL))
       ) {
         $row['log_civicrm_entity_log_action'] = $newAction;
       }
@@ -255,7 +258,7 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
 
       $date = CRM_Utils_Date::isoToMysql($row['log_civicrm_entity_log_date']);
 
-      if (in_array(CRM_Utils_Array::value('log_civicrm_entity_log_action', $row), ['Update', 'Delete'])) {
+      if (in_array(($row['log_civicrm_entity_log_action'] ?? NULL), ['Update', 'Delete'])) {
         $row = $this->addDetailReportLinksToRow($baseQueryCriteria, $row);
       }
 
@@ -293,7 +296,7 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
     $entity = $this->currentLogTable;
 
     $detail = $this->_logTables[$entity];
-    $tableName = CRM_Utils_Array::value('table_name', $detail, $entity);
+    $tableName = $detail['table_name'] ?? $entity;
     $clause = $detail['entity_table'] ?? NULL;
     $clause = $clause ? "AND entity_log_civireport.entity_table = 'civicrm_contact'" : NULL;
 
@@ -333,6 +336,7 @@ LEFT  JOIN civicrm_contact altered_by_contact_civireport
   protected function addDetailReportLinksToRow($baseQueryCriteria, $row) {
     $q = $baseQueryCriteria;
     $q .= (!empty($row['log_civicrm_entity_altered_contact'])) ? '&alteredName=' . $row['log_civicrm_entity_altered_contact'] : '';
+    $q .= (!empty($row['log_civicrm_entity_altered_contact_id'])) ? '&cid=' . $row['log_civicrm_entity_altered_contact_id'] : '';
     $q .= (!empty($row['altered_by_contact_display_name'])) ? '&alteredBy=' . $row['altered_by_contact_display_name'] : '';
     $q .= (!empty($row['log_civicrm_entity_log_user_id'])) ? '&alteredById=' . $row['log_civicrm_entity_log_user_id'] : '';