From 3b45d110dcb56056dc94bdd16a7f1779dad2c75f Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 15 Mar 2016 15:32:22 +1300 Subject: [PATCH] CRM-18193 adapt reports to expect a 17 char string rather than 24 char varchar for log_conn_id This is in anticipation of us converting to unique IDs for these fields --- CRM/Logging/Differ.php | 10 ++++++---- CRM/Logging/ReportDetail.php | 23 +++++++++++++++-------- CRM/Logging/ReportSummary.php | 4 ++-- CRM/Logging/Reverter.php | 6 ++++-- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 29af786f29..d96db96c9f 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -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'), ); diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php index 72ee23e690..a77c483079 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -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); + } + } diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index 8fab3028d4..402ab2f9a6 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -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) { diff --git a/CRM/Logging/Reverter.php b/CRM/Logging/Reverter.php index 1c35fdd6ed..8b2e5668fc 100644 --- a/CRM/Logging/Reverter.php +++ b/CRM/Logging/Reverter.php @@ -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); -- 2.25.1