Skip to content

Commit

Permalink
Merge pull request #18126 from eileenmcnaughton/dupe529
Browse files Browse the repository at this point in the history
dev/core#1934 fix regression on merging contacts with settings using contact_id
  • Loading branch information
seamuslee001 authored Aug 11, 2020
2 parents e1772c4 + 2297a28 commit 520d760
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,17 @@ public static function moveContactBelongings($mergeHandler, $tables, $tableOpera
continue;
}

if ($table === 'civicrm_setting') {
// Per https://lab.civicrm.org/dev/core/-/issues/1934
// Note this line is not unit tested as yet as a quick-fix for a regression
// but it would be better to do a SELECT request & only update if needed (as a general rule
// more selects & less UPDATES will result in less deadlocks while de-duping.
// Note the delete is not important here - it can stay with the deleted contact on the
// off chance they get restored.
$sqls[] = "UPDATE IGNORE civicrm_setting SET contact_id = $mainId WHERE contact_id = $otherId";
continue;
}

// use UPDATE IGNORE + DELETE query pair to skip on situations when
// there's a UNIQUE restriction on ($field, some_other_field) pair
if (isset($cidRefs[$table])) {
Expand Down

0 comments on commit 520d760

Please sign in to comment.