Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] move gathering of location info to relevant function (towards dev/core#723) #14142

Merged
merged 1 commit into from
Apr 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ public static function moveAllBelongings($mainId, $otherId, $migrationInfo, $che

$qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
$relTables = CRM_Dedupe_Merger::relTables();
$submittedCustomFields = $moveTables = $locationMigrationInfo = $tableOperations = $removeTables = [];
$submittedCustomFields = $moveTables = $tableOperations = $removeTables = [];

foreach ($migrationInfo as $key => $value) {
if ($value == $qfZeroBug) {
Expand All @@ -1625,10 +1625,6 @@ public static function moveAllBelongings($mainId, $otherId, $migrationInfo, $che
elseif (in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) && $value != NULL) {
$submitted[substr($key, 5)] = $value;
}
// Set up initial information for handling migration of location blocks
elseif (substr($key, 0, 14) == 'move_location_' and $value != NULL) {
$locationMigrationInfo[$key] = $value;
}
elseif (substr($key, 0, 15) == 'move_rel_table_' and $value == '1') {
$moveTables = array_merge($moveTables, $relTables[substr($key, 5)]['tables']);
if (array_key_exists('operation', $migrationInfo)) {
Expand All @@ -1643,7 +1639,7 @@ public static function moveAllBelongings($mainId, $otherId, $migrationInfo, $che
$removeTables = array_merge($moveTables, $relTables[substr($key, 5)]['tables']);
}
}
self::mergeLocations($mainId, $otherId, $locationMigrationInfo, $migrationInfo);
self::mergeLocations($mainId, $otherId, $migrationInfo);

// **** Do contact related migrations
$customTablesToCopyValues = self::getAffectedCustomTables($submittedCustomFields);
Expand Down Expand Up @@ -2234,14 +2230,16 @@ public static function getMergeContactDetails($contact_id) {
*
* @param int $mainId
* @param int $otherId
* @param array $locationMigrationInfo
* Portion of the migration_info that holds location migration information.
*
* @param array $migrationInfo
* Migration info for the merge. This is passed to the hook as informational only.
*/
public static function mergeLocations($mainId, $otherId, $locationMigrationInfo, $migrationInfo) {
foreach ($locationMigrationInfo as $key => $value) {
public static function mergeLocations($mainId, $otherId, $migrationInfo) {
foreach ($migrationInfo as $key => $value) {
$isLocationField = (substr($key, 0, 14) == 'move_location_' and $value != NULL);
if (!$isLocationField) {
continue;
}
$locField = explode('_', $key);
$fieldName = $locField[2];
$fieldCount = $locField[3];
Expand Down