From f8fb0608d94bba2aa54f275897661c62d64fa1d2 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 17 Jul 2019 10:27:54 +1200 Subject: [PATCH] Stop passing exportParams & sqlColumns around --- CRM/Export/BAO/Export.php | 18 +++--------------- CRM/Export/BAO/ExportProcessor.php | 16 +--------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index 1cd09f92c0..6b5fdf2946 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -163,18 +163,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c list($outputColumns, $metadata) = $processor->getExportStructureArrays(); if ($processor->isMergeSameAddress()) { - //make sure the addressee fields are selected - //while using merge same address feature - // some columns are required for assistance incase they are not already present - $exportParams['merge_same_address']['temp_columns'] = $processor->getAdditionalFieldsForSameAddressMerge(); - // This is silly - we should do this at the point when the array is used... - if (isset($exportParams['merge_same_address']['temp_columns']['id'])) { - unset($exportParams['merge_same_address']['temp_columns']['id']); - $exportParams['merge_same_address']['temp_columns']['civicrm_primary_id'] = 1; - } - // @todo - this is a temp fix - ideally later we don't set stuff only to unset it. - // test exists covering this... - foreach (array_keys($exportParams['merge_same_address']['temp_columns']) as $field) { + foreach (array_keys($processor->getAdditionalFieldsForSameAddressMerge()) as $field) { $processor->setColumnAsCalculationOnly($field); } } @@ -248,7 +237,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c // do merge same address and merge same household processing if ($mergeSameAddress) { - $processor->mergeSameAddress($sqlColumns, $exportParams); + $processor->mergeSameAddress(); } // call export hook @@ -464,7 +453,6 @@ VALUES $sqlValueString */ public static function writeCSVFromTable($headerRows, $sqlColumns, $processor) { $exportTempTable = $processor->getTemporaryTable(); - $exportMode = $processor->getExportMode(); $writeHeader = TRUE; $offset = 0; $limit = self::EXPORT_ROW_COUNT; @@ -485,7 +473,7 @@ LIMIT $offset, $limit while ($dao->fetch()) { $row = []; - foreach ($sqlColumns as $column => $dontCare) { + foreach (array_keys($processor->getSQLColumns()) as $column) { $row[$column] = $dao->$column; } $componentDetails[] = $row; diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index 04f62644d7..7971f9cc89 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -1985,11 +1985,8 @@ class CRM_Export_BAO_ExportProcessor { /** * Merge contacts with the same address. - * - * @param $sqlColumns - * @param array $exportParams */ - public function mergeSameAddress(&$sqlColumns, $exportParams) { + public function mergeSameAddress() { $tableName = $this->getTemporaryTable(); // check if any records are present based on if they have used shared address feature, @@ -2082,17 +2079,6 @@ WHERE id IN ( $deleteIDString ) "; CRM_Core_DAO::executeQuery($sql); } - - // unset temporary columns that were added for postal mailing format - // @todo - this part is pretty close to ready to be removed.... - if (!empty($exportParams['merge_same_address']['temp_columns'])) { - $unsetKeys = array_keys($sqlColumns); - foreach ($unsetKeys as $headerKey => $sqlColKey) { - if (array_key_exists($sqlColKey, $exportParams['merge_same_address']['temp_columns'])) { - unset($sqlColumns[$sqlColKey]); - } - } - } } /** -- 2.25.1