From 1006edc9d79d2eb54beeb210477ccc80b27eb011 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 22 Apr 2022 05:14:15 +1200 Subject: [PATCH] Remove another good intention - unused variables 100% of the responses from setActiveFields are discarded and 100% of the time the erroneousField value is not used. Hence it makes sense to remove them.... --- CRM/Contact/Import/Parser/Contact.php | 3 +-- CRM/Custom/Import/Parser/Api.php | 4 +--- CRM/Event/Import/Parser/Participant.php | 5 +---- CRM/Import/Parser.php | 18 +----------------- CRM/Member/Import/Parser/Membership.php | 4 ++-- 5 files changed, 6 insertions(+), 28 deletions(-) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index b9a80bf4d3..d77c482883 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -287,8 +287,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { * CRM_Import_Parser::ERROR or CRM_Import_Parser::VALID */ public function summary(&$values): int { - $erroneousField = NULL; - $this->setActiveFieldValues($values, $erroneousField); + $this->setActiveFieldValues($values); $rowNumber = (int) ($values[count($values) - 1]); $errorMessage = NULL; $errorRequired = FALSE; diff --git a/CRM/Custom/Import/Parser/Api.php b/CRM/Custom/Import/Parser/Api.php index fa1a0e308f..32428eb6e3 100644 --- a/CRM/Custom/Import/Parser/Api.php +++ b/CRM/Custom/Import/Parser/Api.php @@ -110,13 +110,11 @@ class CRM_Custom_Import_Parser_Api extends CRM_Import_Parser { * @see CRM_Custom_Import_Parser_BaseClass::summary() */ public function summary(&$values) { - $erroneousField = NULL; - $response = $this->setActiveFieldValues($values, $erroneousField); + $this->setActiveFieldValues($values); $errorRequired = FALSE; $missingField = ''; $this->_params = &$this->getActiveFieldParams(); - $formatted = $this->_params; $this->_updateWithId = FALSE; $this->_parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'), FALSE); diff --git a/CRM/Event/Import/Parser/Participant.php b/CRM/Event/Import/Parser/Participant.php index db4340892c..8f6ae41ee7 100644 --- a/CRM/Event/Import/Parser/Participant.php +++ b/CRM/Event/Import/Parser/Participant.php @@ -155,10 +155,7 @@ class CRM_Event_Import_Parser_Participant extends CRM_Import_Parser { * the result of this processing */ public function summary(&$values) { - $erroneousField = NULL; - - $response = $this->setActiveFieldValues($values, $erroneousField); - $errorRequired = FALSE; + $this->setActiveFieldValues($values); $index = -1; if ($this->_eventIndex > -1 && $this->_eventTitleIndex > -1) { diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index de78e35260..f7645c8c9f 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -255,12 +255,8 @@ abstract class CRM_Import_Parser { * * @param array $elements * array. - * @param $erroneousField - * reference. - * - * @return int */ - public function setActiveFieldValues($elements, &$erroneousField = NULL) { + public function setActiveFieldValues($elements): void { $maxCount = count($elements) < $this->_activeFieldCount ? count($elements) : $this->_activeFieldCount; for ($i = 0; $i < $maxCount; $i++) { $this->_activeFields[$i]->setValue($elements[$i]); @@ -270,18 +266,6 @@ abstract class CRM_Import_Parser { for (; $i < $this->_activeFieldCount; $i++) { $this->_activeFields[$i]->resetValue(); } - - // now validate the fields and return false if error - $valid = self::VALID; - for ($i = 0; $i < $this->_activeFieldCount; $i++) { - if (!$this->_activeFields[$i]->validate()) { - // no need to do any more validation - $erroneousField = $i; - $valid = self::ERROR; - break; - } - } - return $valid; } /** diff --git a/CRM/Member/Import/Parser/Membership.php b/CRM/Member/Import/Parser/Membership.php index 835ad707d4..7636b53847 100644 --- a/CRM/Member/Import/Parser/Membership.php +++ b/CRM/Member/Import/Parser/Membership.php @@ -508,8 +508,8 @@ class CRM_Member_Import_Parser_Membership extends CRM_Import_Parser { * the result of this processing */ public function summary(&$values) { - $erroneousField = NULL; - $this->setActiveFieldValues($values, $erroneousField); + + $this->setActiveFieldValues($values); $errorRequired = FALSE; -- 2.25.1