-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#5433 Add legacydedupefinder #31689
base: master
Are you sure you want to change the base?
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/core/-/issues/5433 |
*/ | ||
function legacydedupefinder_civicrm_config(&$config): void { | ||
_legacydedupefinder_civix_civicrm_config($config); | ||
\Civi::dispatcher()->addListener('hook_civicrm_findExistingDuplicates', ['\Civi\LegacyFinder\Finder', 'findExistingDuplicates'], -5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn''t think this was still the right way - but my reading of https://docs.civicrm.org/dev/en/latest/hooks/usage/symfony/ is that unless it's a BAO class or in a very specific location then it still is
|
||
/** | ||
* The CiviCRM duplicate discovery engine is based on an | ||
* algorithm designed by David Strauss <[email protected]>. | ||
*/ | ||
class CRM_Dedupe_BAO_DedupeRuleGroup extends CRM_Dedupe_DAO_DedupeRuleGroup { | ||
class CRM_Dedupe_BAO_DedupeRuleGroup extends CRM_Dedupe_DAO_DedupeRuleGroup implements \Symfony\Component\EventDispatcher\EventSubscriberInterface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton this should be the \Civi\Core\HookInterface not Event Subscriber Interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seamuslee001 I didn't really figure out which is which based on the docs - but this one seems to allow me to specify the weight
class CRM_Dedupe_BAO_DedupeRuleGroup extends CRM_Dedupe_DAO_DedupeRuleGroup { | ||
class CRM_Dedupe_BAO_DedupeRuleGroup extends CRM_Dedupe_DAO_DedupeRuleGroup implements \Symfony\Component\EventDispatcher\EventSubscriberInterface { | ||
|
||
public static function getSubscribedEvents(): array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed one switched to using the hookInterface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do you specify weight with hook interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right @eileenmcnaughton if you want to specify priority level you need to use getSubscribedEvents()
* | ||
* @return void | ||
*/ | ||
public static function hook_civicrm_findExistingDuplicates(\Civi\Core\Event\GenericHookEvent $event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should change to self_hook_civicrm_findExistingDuplicates as per https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/BAO/OptionGroup.php#L83
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @eileenmcnaughton did is correct. Since she needs to specify priority this is the way to do it.
===== Overview ==== This adds a new extension for existing dedupe finder behaviour, allowing us to support the hook that is jammed in the middle of the dedupe finder code going forwards without being blocked by it (I have an existing PR that cuts many hours off the dedupe query but it is bending over backwards to work alongside the legacy attempts to allow integration). The new extension is enabled on install and on upgrade and there is no behaviour change unless a site admin disables it. If they choose to do so then 1) the legacy hook & legacy reserved query wrangling will no longer be called 2) dedupe queries will speed up once the blocked code is also merged civicrm#30591
c6314b1
to
b987e2a
Compare
@@ -47,7 +47,7 @@ php GenerateData.php | |||
|
|||
## Prune local data | |||
$MYSQLCMD -e "DROP TABLE IF EXISTS civicrm_install_canary; DELETE FROM civicrm_cache; DELETE FROM civicrm_setting;" | |||
$MYSQLCMD -e "DELETE FROM civicrm_extension WHERE full_name NOT IN ('sequentialcreditnotes', 'eventcart', 'greenwich', 'org.civicrm.search_kit', 'org.civicrm.afform', 'authx', 'org.civicrm.flexmailer', 'financialacls', 'contributioncancelactions', 'recaptcha', 'ckeditor4', 'legacycustomsearches', 'civiimport', 'message_admin') and full_name NOT LIKE 'civi_%';" | |||
$MYSQLCMD -e "DELETE FROM civicrm_extension WHERE full_name NOT IN ('sequentialcreditnotes', 'eventcart', 'greenwich', 'org.civicrm.search_kit', 'org.civicrm.afform', 'authx', 'org.civicrm.flexmailer', 'financialacls', 'contributioncancelactions', 'recaptcha', 'ckeditor4', 'legacycustomsearches', 'civiimport', 'message_admin', 'legacydedupefinder) and full_name NOT LIKE 'civi_%';" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this missing a quote? It should be 'legacydedupefinder'
instead of 'legacydedupefinder
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree it should be
$MYSQLCMD -e "DELETE FROM civicrm_extension WHERE full_name NOT IN ('sequentialcreditnotes', 'eventcart', 'greenwich', 'org.civicrm.search_kit', 'org.civicrm.afform', 'authx', 'org.civicrm.flexmailer', 'financialacls', 'contributioncancelactions', 'recaptcha', 'ckeditor4', 'legacycustomsearches', 'civiimport', 'message_admin', 'legacydedupefinder) and full_name NOT LIKE 'civi_%';" | |
$MYSQLCMD -e "DELETE FROM civicrm_extension WHERE full_name NOT IN ('sequentialcreditnotes', 'eventcart', 'greenwich', 'org.civicrm.search_kit', 'org.civicrm.afform', 'authx', 'org.civicrm.flexmailer', 'financialacls', 'contributioncancelactions', 'recaptcha', 'ckeditor4', 'legacycustomsearches', 'civiimport', 'message_admin', 'legacydedupefinder') and full_name NOT LIKE 'civi_%';" |
Overview
This adds a new extension for existing dedupe finder behaviour, allowing us to support the hook that is jammed in the middle of the dedupe finder code going forwards without being blocked by it (I have an existing PR that cuts many hours off the dedupe query but it is bending over backwards to work alongside the legacy attempts to allow integration).
Before
We know how to speed up dedupe queries #30591 but are working really hard around the legacy hook and the existing PR is having to rely on crazy methodology. The hook
dupeQuery()
is not one that has had much adoption, nor has the idea of writing custom improvements for the reserved queries. However, these 2 things have been long-standing blockers to improving performanceAfter
The new extension is enabled on install and on upgrade and there is no behaviour change unless a site admin disables it. If they choose to do so then
the legacy hook & legacy reserved query wrangling will no longer be called
dedupe queries will speed up once the blocked code is also merged Fix dedupe query wrangling to combine queries where 2 fields in the same table are always used together #30591
Technical Details
The code works by adding a new hook
findExistingDuplicates(array &$duplicates, array $ruleGroupIDs, array $whereClauses, bool $checkPermissions)
The hook is implemented by the new extension
legacydedupefinder
with a weight of -5 and by core with a weight of -20legacydedupefinder
callsstopPropagation()
meaning that if it is enabled the core code will not be hit. Any custom extensions that give no specific thought to it will wind up with a weight of 0 - meaning they get called first, which feels like it would be as expected. Once finalised I will document this.The function in the core code and in the extension is currently the same, except the core code is passing a parameter to
fillTable
to block legacy hooks from being called. Once this is merged the goal is to separate out & re-write the core function.Before that I want to look at the second code path and attempt to do the same for it - the challenge is I really want to pass out apiv4 params to the function, not v3 https://lab.civicrm.org/dev/core/-/issues/5433
Comments
The extension is currently not hidden but if I don't get to where I want to before forking I will hide it so people do not disable it until the new hooks are settled in
@mattwire @colemanw