Remove deprecation from a hook that's actually uniquely useful #25628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
hook_civicrm_merge
has a sub-hookcidRefs
, documented here. This subhook has been deprecated since 2018 (@eileenmcnaughton) -- see the code change and the documentation change.I'm glad the sub-hook was never removed after it was deprecated, because it actually offers something that
hook_civicrm_entityTypes
(the suggested replacement) does not: an opportunity to prevent an entity from being merged along with its associated Contact.cidRefs
is invoked only in the context of a merge, and there are some times when that's very helpful. I have a Flag entity that's joined to the Contact entity. In most contexts, I want the Flag's FK tocivicrm_contact
to behave as usual: the join should be accessible through API4 so that you can get the Contact for a Flag and the Flags for a Contact; a Flag should be cascade-deleted when its Contact is deleted. But, in my use case, Flags should not be reassigned when a Contact is merged into another Contact. ThecidRefs
sub-hook lets me do this by simply writingentityTypes
is a more blunt instrument. I can't accomplish what I want to do withentityTypes
or with any hook besidescidRefs
, to my knowledge.Before
If you use the
cidRefs
phase ofhook_civicrm_merge
, you get a deprecation notice in your logs.After
Nice control over the contact merge process, in peace and quiet.