CRM-18193 adapt reports to expect a 17 char string rather than 24 char varchar for...
authoreileen <emcnaughton@wikimedia.org>
Tue, 15 Mar 2016 02:32:22 +0000 (15:32 +1300)
committerEileen <eileen@fuzion.co.nz>
Sat, 23 Apr 2016 03:51:09 +0000 (03:51 +0000)
This is in anticipation of us converting to unique IDs for these fields

CRM/Logging/Differ.php
CRM/Logging/ReportDetail.php
CRM/Logging/ReportSummary.php
CRM/Logging/Reverter.php

index 29af786f29ff2d9acb5417cd85ec39cf1158e577..d96db96c9fa2f869e5d68f4cdbf2114ebfe3085b 100644 (file)
@@ -39,7 +39,9 @@ class CRM_Logging_Differ {
   private $interval;
 
   /**
-   * @param int $log_conn_id
+   * Class constructor.
+   *
+   * @param string $log_conn_id
    * @param $log_date
    * @param string $interval
    */
@@ -77,7 +79,7 @@ class CRM_Logging_Differ {
     $diffs = array();
 
     $params = array(
-      1 => array($this->log_conn_id, 'Integer'),
+      1 => array($this->log_conn_id, 'String'),
       2 => array($this->log_date, 'String'),
     );
 
@@ -166,7 +168,7 @@ WHERE lt.log_conn_id = %1 AND
     $diffs = array();
 
     $params = array(
-      1 => array($this->log_conn_id, 'Integer'),
+      1 => array($this->log_conn_id, 'String'),
       2 => array($this->log_date, 'String'),
       3 => array($id, 'Integer'),
     );
@@ -336,7 +338,7 @@ WHERE lt.log_conn_id = %1 AND
     $values = array();
 
     $params = array(
-      1 => array($this->log_conn_id, 'Integer'),
+      1 => array($this->log_conn_id, 'String'),
       2 => array($this->log_date, 'String'),
       3 => array($table, 'String'),
     );
index 72ee23e6904781a9bcb0d9358c18f5f2aba44a46..a77c483079545f574f86b1d3e3496fe777c1cb46 100644 (file)
@@ -61,14 +61,7 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form {
 
     $this->storeDB();
 
-    $this->log_conn_id = CRM_Utils_Request::retrieve('log_conn_id', 'Integer', CRM_Core_DAO::$_nullObject);
-    $this->log_date = CRM_Utils_Request::retrieve('log_date', 'String', CRM_Core_DAO::$_nullObject);
-    $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
-    $this->raw = CRM_Utils_Request::retrieve('raw', 'Boolean', CRM_Core_DAO::$_nullObject);
-
-    $this->altered_name = CRM_Utils_Request::retrieve('alteredName', 'String', CRM_Core_DAO::$_nullObject);
-    $this->altered_by = CRM_Utils_Request::retrieve('alteredBy', 'String', CRM_Core_DAO::$_nullObject);
-    $this->altered_by_id = CRM_Utils_Request::retrieve('alteredById', 'Integer', CRM_Core_DAO::$_nullObject);
+    $this->parsePropertiesFromUrl();
 
     parent::__construct();
 
@@ -255,4 +248,18 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form {
     }
   }
 
+  /**
+   * Get the properties that might be in the URL.
+   */
+  protected function parsePropertiesFromUrl() {
+    $this->log_conn_id = CRM_Utils_Request::retrieve('log_conn_id', 'String', CRM_Core_DAO::$_nullObject);
+    $this->log_date = CRM_Utils_Request::retrieve('log_date', 'String', CRM_Core_DAO::$_nullObject);
+    $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
+    $this->raw = CRM_Utils_Request::retrieve('raw', 'Boolean', CRM_Core_DAO::$_nullObject);
+
+    $this->altered_name = CRM_Utils_Request::retrieve('alteredName', 'String', CRM_Core_DAO::$_nullObject);
+    $this->altered_by = CRM_Utils_Request::retrieve('alteredBy', 'String', CRM_Core_DAO::$_nullObject);
+    $this->altered_by_id = CRM_Utils_Request::retrieve('alteredById', 'Integer', CRM_Core_DAO::$_nullObject);
+  }
+
 }
index 8fab3028d4953d745b39ee0bdb83e1b9edff9503..402ab2f9a6a98716efd47b7e5733e9878a0149fb 100644 (file)
@@ -224,7 +224,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form {
     if (!empty($this->_params['fields']['altered_contact'])) {
       $tempColumns .= ", altered_contact varchar(128)";
     }
-    $tempColumns .= ", altered_contact_id int(10), log_conn_id int(11), is_deleted tinyint(4)";
+    $tempColumns .= ", altered_contact_id int(10), log_conn_id varchar(17), is_deleted tinyint(4)";
     if (!empty($this->_params['fields']['display_name'])) {
       $tempColumns .= ", display_name varchar(128)";
     }
@@ -401,7 +401,7 @@ WHERE  log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1";
       $sql = "select {$this->_logTables[$entity]['action_column']} from `{$this->loggingDB}`.{$entity} where id = %1 AND log_conn_id = %2";
       $newAction = CRM_Core_DAO::singleValueQuery($sql, array(
         1 => array($id, 'Integer'),
-        2 => array($connId, 'Integer'),
+        2 => array($connId, 'String'),
       ));
 
       switch ($entity) {
index 1c35fdd6ed01b658c3fc659137a36c40d0d459c3..8b2e5668fc874a5649a3b11ed36a1684abc074dc 100644 (file)
@@ -36,7 +36,9 @@ class CRM_Logging_Reverter {
   private $log_date;
 
   /**
-   * @param int $log_conn_id
+   * Class constructor.
+   *
+   * @param string $log_conn_id
    * @param $log_date
    */
   public function __construct($log_conn_id, $log_date) {
@@ -175,7 +177,7 @@ class CRM_Logging_Reverter {
                 ORDER BY log_date DESC LIMIT 1
             ";
       $params = array(
-        1 => array($this->log_conn_id, 'Integer'),
+        1 => array($this->log_conn_id, 'String'),
         2 => array($this->log_date, 'String'),
       );
       $cid = CRM_Core_DAO::singleValueQuery($query, $params);