CRM-20858: Fix Merging of Unselected Custom Fields and Refactor Code
authorCamilo Rodriguez <camilo@compucorp.co.uk>
Wed, 9 Aug 2017 14:10:02 +0000 (14:10 +0000)
committerCamilo Rodriguez <camilo@compucorp.co.uk>
Wed, 9 Aug 2017 14:15:58 +0000 (14:15 +0000)
commitae2346d481a444de71eaf97b58432a253fe36db1
treeeb3e6c5e3891eb1da752f5c860502ff235d04e69
parentdba77ae8876d837fe9c9d1a256ad243598f6ce9b
CRM-20858: Fix Merging of Unselected Custom Fields and Refactor Code

When a Custom Group had more than one custom field and only some of those
fields were selected to be merged, all the fields in the custom group were
merged. This happened exclusively on contacts that had no record on the
custom group's table.

Fixed this by inserting a record on the custom group table before updating
references from source contact to target contact, this way, all values in the
custom group will start empty and only submitted values will get assigned.

Also refactored the solution to make it easier to read and used more descriptive
variable and function names.
CRM/Dedupe/Merger.php [changed mode: 0644->0755]