Add system status check for missing dedupe rules #22369
Merged
+81
−0
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
As discussed in core#2918, CiviCRM assumes that
Unsupervised
andSupervised
dedupe rules will always exist, but allows the system to get into a state where onlyGeneral
rules are actually configured. This adds a system check to warn when eitherUnsupervised
orSupervised
dedupe rules are missing.Before
It was possible to configure CiviCRM without either
Unsupervised
orSupervised
dedupe rules. This can lead to exceptions being thrown, blocking certain functionality from working correctly. For example:After
If dedupe rules have not been configured correctly, system messages will be shown warning the user that they should review their configuration. A link to the dedupe contacts screen is included, and from here the configuration can be changed:
Note that it's still too easy (in my opinion) to get into a bad state, and I'd still like to implement the UI improvements suggested on core#2918 if I can find time.
Technical Details
The code felt tidiest when split into two check functions, both using a shared
getContactTypesForRule
method. This does mean that two very similar database queries are required, rather than a single query. However, I belive this should be a fairly efficient database call and so I don't think this should be a massive problem.I've not included tests because:
CRM/Utils/Check/Component/
had tests which I could use as a reference.Comments
I wasn't 100% sure which severity and icon to go for. I've settled on
\Psr\Log\LogLevel::WARNING
andfa-server
, but did very much wonder if\Psr\Log\LogLevel::ERROR
would be more appropriate.