Skip to content

Commit

Permalink
Move the qfbug handling to it's own function
Browse files Browse the repository at this point in the history
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....
  • Loading branch information
eileenmcnaughton committed Apr 27, 2019
1 parent b632d5e commit 3c7ba75
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1609,14 +1609,11 @@ public static function moveAllBelongings($mainId, $otherId, $migrationInfo, $che
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;
Expand Down Expand Up @@ -2408,4 +2405,25 @@ protected static function dedupePair(&$migrationInfo, &$resultStats, &$deletedCo
}
}

/**
* 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
*
* @return array
*/
protected static function swapOutFieldsAffectedByQFZeroBug(&$migrationInfo) {
$qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
foreach ($migrationInfo as $key => &$value) {
if ($value == $qfZeroBug) {
$value = '0';
}
}
}

}

0 comments on commit 3c7ba75

Please sign in to comment.