From 54ed517e1abc59dcde0097214eb6b2dfc16ca9de Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 27 Apr 2019 15:58:34 +1200 Subject: [PATCH] Move the qfbug handling to it's own function This is a really toxi function. In order to save the pain or iterating multiple times through a small array we are dealing with an awful lot of complexity. I'm changing this to iterate through it multiple times in order to rationalise the code - I think performance is minimal & being able to read the code.... --- CRM/Dedupe/Merger.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 869454b0ca..511259a983 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -1609,14 +1609,11 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m return FALSE; } - $qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9'; $relTables = CRM_Dedupe_Merger::relTables(); $submittedCustomFields = $moveTables = $locationMigrationInfo = $tableOperations = $removeTables = []; + self::swapOutFieldsAffectedByQFZeroBug($migrationInfo); foreach ($migrationInfo as $key => $value) { - if ($value == $qfZeroBug) { - $value = '0'; - } if (substr($key, 0, 12) == 'move_custom_' && $value != NULL) { $submitted[substr($key, 5)] = $value; @@ -2408,4 +2405,23 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m } } + /** + * Replace the pseudo QFKey with zero if it is present. + * + * @todo - on the slim chance this is still relevant it should be moved to the form layer. + * + * Details about this bug are somewhat obscured by the move from svn but perhaps JIRA + * can still help. + * + * @param array $migrationInfo + */ + protected static function swapOutFieldsAffectedByQFZeroBug(&$migrationInfo) { + $qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9'; + foreach ($migrationInfo as $key => &$value) { + if ($value == $qfZeroBug) { + $value = '0'; + } + } + } + } -- 2.25.1