-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/core#1109 - Fix merge not updating ContactReference fields #14983
dev/core#1109 - Fix merge not updating ContactReference fields #14983
Conversation
This fixes an issue that causes ContactReference custom fields pointing to a duplicated contact that's being merged to not be updated to the main (surviving) contact.
(Standard links)
|
@@ -2398,7 +2399,26 @@ public static function appendCustomTablesExtendingContacts(&$cidRefs) { | |||
$customValueTables = CRM_Core_BAO_CustomGroup::getAllCustomGroupsByBaseEntity('Contact'); | |||
$customValueTables->find(); | |||
while ($customValueTables->fetch()) { | |||
$cidRefs[$customValueTables->table_name] = ['entity_id']; | |||
$cidRefs[$customValueTables->table_name][] = 'entity_id'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NFC - just a bit more defensive as it doesn't muck things up if the call order is changed.
@@ -918,7 +992,7 @@ public function setupMatchData() { | |||
foreach ($fixtures as $fixture) { | |||
$contactID = $this->individualCreate($fixture); | |||
$this->contacts[] = array_merge($fixture, ['id' => $contactID]); | |||
sleep(5); | |||
sleep(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be enough?
I stepped through this test in debugger & it all makes sense & I agree that this data should be migrated - merging |
Thanks @eileenmcnaughton! |
Overview
When duplicates are merged, custom fields and other records pointing to the duplicate contact (i.e. the one that will be deleted) should be redirected to the main (surviving) contact.
Before
When a custom field of type
ContactReference
exists, and values point to a contact used as the duplicate when merging, these records will not be updated to point to the main contact.After
ContactReference
custom fields are updated to point to the main contact.Technical Details
CRM_Core_DAO::getReferencesToContactTable()
, which was updated to includeContactReference
fields, is also used by some logging features, includingCRM_Logging_ReportDetail
. Logging code generally has okay test coverage and I've manually tested some bits in the report.