From 5f97768e2bfa7198e2fe2c99ffd8ca8bcaec0d5a Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 24 Apr 2022 09:57:08 +1200 Subject: [PATCH] [REF] [Import] Contribution import - clarify return codes, remove handling for unused CONFLICT --- CRM/Contribute/Import/Parser/Contribution.php | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index 4a639e2f5a..adacc4140c 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -243,10 +243,8 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser { if ($mode == self::MODE_MAPFIELD) { $returnCode = CRM_Import_Parser::VALID; } - elseif ($mode == self::MODE_PREVIEW) { - $returnCode = $this->preview($values); - } - elseif ($mode == self::MODE_SUMMARY) { + // Note that import summary appears to be unused + elseif ($mode == self::MODE_PREVIEW || $mode == self::MODE_SUMMARY) { $returnCode = $this->summary($values); } elseif ($mode == self::MODE_IMPORT) { @@ -715,27 +713,14 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser { } } - /** - * Handle the values in preview mode. - * - * @param array $values - * The array of values belonging to this line. - * - * @return bool - * the result of this processing - */ - public function preview(&$values) { - return $this->summary($values); - } - /** * Handle the values in summary mode. * * @param array $values * The array of values belonging to this line. * - * @return bool - * the result of this processing + * @return int + * CRM_Import_Parser::VALID or CRM_Import_Parser::ERROR */ public function summary(&$values) { $this->setActiveFieldValues($values); @@ -769,14 +754,21 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser { * @param array $values * The array of values belonging to this line. * - * @return bool - * the result of this processing + * @return int + * the result of this processing - one of + * - CRM_Import_Parser::VALID + * - CRM_Import_Parser::ERROR + * - CRM_Import_Parser::SOFT_CREDIT_ERROR + * - CRM_Import_Parser::PLEDGE_PAYMENT_ERROR + * - CRM_Import_Parser::DUPLICATE + * - CRM_Import_Parser::SOFT_CREDIT (successful creation) + * - CRM_Import_Parser::PLEDGE_PAYMENT (successful creation) */ public function import($onDuplicate, &$values) { // first make sure this is a valid line $response = $this->summary($values); if ($response != CRM_Import_Parser::VALID) { - return $response; + return CRM_Import_Parser::ERROR; } $params = &$this->getActiveFieldParams(); -- 2.25.1