Fix export merge for contacts with shared addresses
Currently when you export contacts with the same address contacts who have the same street address, city, state are merged, but all the handling for those who are linked by civicrm_address.master_id is bypassed.
I'm pretty sure this broke quite a long time ago. However, it was only picked up by @monish.deb in the course of addressing another issue. I believe that it has gone largely unnoticed because generally the code enforces that the setting of master_id updates the address to match - causing them to still be exported on that basis.
However, the handling of display name differs between the by-passed-shared-via-master-id & shared-via-sameness.
Contact 1 | Contact 2 | Contact 3 | Result with shared via sameness | 'feels right' | |
---|---|---|---|---|---|
Bob | Sarah | Jill | Dear Bob, Sarah, Jill | Dear Bob, | Dear Bob, Sarah, Jill |
Big Business Limited | Sarah | Jill | Dear Big Business Limited , Sarah, Jill | Dear Big Business Limited , | Dear Big Business Limited |
Big Business Limited | Sarah | Jill (not shared via master_id) | Dear Big Business Limited , Sarah, Jill | Dear Big Business Limited , Jill (TBC) | Dear Big Business Limited, Jill |
Bob's household | Sarah | Jill | Dear Bob's household, Sarah, Jill | Dear Bob's household, | Dear Bob's household |
Bob's household | Sarah | Jill (not a household member OR shared via master id) | Dear Bob's household, Sarah, Jill | Dear Bob's household, | Dear Bob's household, Jill |
As can be seen 'fixing' this bug will feel like a regression where addresses are shared between individuals. I think the handling needs to be that the name of the shared address owner is used only if that contact is NOT an individual. If there is a shared address owner and that owner contact type is NOT an individual the address owner's detail is used. Otherwise the contact sharing the address's name is appended.