Fixes to dedupe getting dynamic references
Civi 5.26 included PR #17125, "Fix Dedupe entity_tag mangling bug". This introduced the new method CRM_Core_DAO::getDynamicReferencesToTable()
and CRM_Dedupe_MergeHandler::getTablesRelatedToTheMergePair()
. However, there are two bugs in the implementation:
- It assumes that only one dynamic reference can exist between two tables. In addition to extensions that may introduce dynamic references, this is also untrue in core:
civicrm_pcp_block
has two dynamic references tocivicrm_contact
: Bothentity_id
andtarget_entity_id
. - It assumes that the column specifying the entity is always called
entity_table
, and this is hard-coded into the SQL ingetTablesRelatedToTheMergePair()
. However, this column isn't alwaysentity_table
. We should pull the correct column name from the metadata.
I don't think there's a Gitlab ticket for PR #17125, so I'm referencing the PR here instead.