From 072f1e98296a4a9977f2c21920082b5dfb605d55 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 13 Mar 2023 12:10:27 +1300 Subject: [PATCH] Php8.2 fixes in report addToDeveloperTab function --- CRM/Report/Form.php | 29 ++++++++++++++++------------- api/v3/ReportTemplate.php | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index ee3cada4ec12..a584d84cc7ca 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -248,9 +248,13 @@ class CRM_Report_Form extends CRM_Core_Form { protected $_add2groupSupported = TRUE; protected $_groups = NULL; protected $_grandFlag = FALSE; - protected $_rowsFound = NULL; + protected $_rowsFound; + + /** + * @var array + */ protected $_selectAliases = []; - protected $_rollup = NULL; + protected $_rollup; /** * Table containing list of contact IDs within the group filter. @@ -522,9 +526,8 @@ class CRM_Report_Form extends CRM_Core_Form { * * The sql in the report is stored in this variable in order to be returned to api & test calls. * - * @var string + * @var array */ - protected $sqlArray; /** @@ -686,7 +689,7 @@ public function preProcessCommon() { $this->setOutputMode(); - if ($this->_outputMode == 'copy') { + if ($this->_outputMode === 'copy') { $this->_createNew = TRUE; $this->_params = $this->_formValues; $this->_params['view_mode'] = 'criteria'; @@ -1510,7 +1513,7 @@ protected function assignTabs() { * * @param string $sql */ - public function addToDeveloperTab($sql) { + public function addToDeveloperTab(string $sql): void { if (!CRM_Core_Permission::check('view report sql')) { return; } @@ -1525,7 +1528,7 @@ public function addToDeveloperTab($sql) { ]; $this->assignTabs(); - $this->sqlFormattedArray = []; + $sqlFormattedArray = []; $this->sqlArray[] = $sql; foreach ($this->sqlArray as $sql) { foreach (['LEFT JOIN'] as $term) { @@ -1534,8 +1537,8 @@ public function addToDeveloperTab($sql) { foreach (['FROM', 'WHERE', 'GROUP BY', 'ORDER BY', 'LIMIT', ';'] as $term) { $sql = str_replace($term, '

' . $term, ($sql ?? '')); } - $this->sqlFormattedArray[] = $sql; - $this->assign('sql', implode(';



', $this->sqlFormattedArray)); + $sqlFormattedArray[] = $sql; + $this->assign('sql', implode(';



', $sqlFormattedArray)); } $this->assign('sqlModes', $sqlModes = CRM_Utils_SQL::getSqlModes()); @@ -3699,7 +3702,7 @@ public function limit($rowCount = NULL) { $this->_limit = " LIMIT {$this->_offsetValue}, {$this->_limitValue} "; } else { - $this->_limit = " LIMIT " . $this->_limitValue; + $this->_limit = ' LIMIT ' . $this->_limitValue; } } } @@ -3990,8 +3993,8 @@ public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = } $customGroupWhere = ''; if (!empty($permCustomGroupIds)) { - $customGroupWhere = "cg.id IN (" . implode(',', $permCustomGroupIds) . - ") AND"; + $customGroupWhere = 'cg.id IN (' . implode(',', $permCustomGroupIds) . + ') AND'; } $sql = " SELECT cg.table_name, cg.title, cg.extends, cf.id as cf_id, cf.label, @@ -5359,7 +5362,7 @@ protected function addStatisticsToSelect($field, $tableName, $fieldName, $select * @param string $tableName * @param string $fieldName * @param array $field - * @param string $select + * @param array $select * @return array */ protected function addBasicFieldToSelect($tableName, $fieldName, $field, $select) { diff --git a/api/v3/ReportTemplate.php b/api/v3/ReportTemplate.php index 0deb7b998ff2..0ac8ccdedd65 100644 --- a/api/v3/ReportTemplate.php +++ b/api/v3/ReportTemplate.php @@ -143,7 +143,7 @@ function _civicrm_api3_report_template_getrows($params) { $reportInstance->setAddPaging(FALSE); $reportInstance->setOffsetValue($options['offset']); $reportInstance->beginPostProcessCommon(); - $sql = $reportInstance->buildQuery(); + $sql = (string) $reportInstance->buildQuery(); $reportInstance->addToDeveloperTab($sql); $rows = $metadata = $requiredMetadata = []; $reportInstance->buildRows($sql, $rows);