-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
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
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 the docs don't make it very clear. But don't think we should be doing it like this anymore.
I think the "correct" way would be to implement an interface, in this case `https://docs.civicrm.org/dev/en/latest/hooks/usage/symfony/#hookinterface would be fine in Civi/LegacyFinder/Finder.php and make sure you have scan-classes mixin enabled because it's in an extension
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.
c6314b1
to
b987e2a
Compare
test this please |
f240f20
to
c3a8dc5
Compare
ext/legacydedupefinder/info.xml
Outdated
</classloader> | ||
<civix> | ||
<namespace>CRM/Legacydedupefinder</namespace> | ||
<format>24.09.1</format> |
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 As this is going into core can we generate with latest civix please?
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.
@mattwire done - I've also made it 'hidden' for now - until I've migrated the second hook
c3a8dc5
to
4a89208
Compare
@@ -29,6 +29,7 @@ class CRM_Upgrade_Incremental_php_FiveEightyTwo extends CRM_Upgrade_Incremental_ | |||
*/ | |||
public function upgrade_5_82_alpha1($rev): void { | |||
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); | |||
$this->addSimpleExtensionTask(ts('enable dedupe backward compatibility'), ['legacydedupefinder']); |
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 I think this needs to be moved to SixZero.
4a89208
to
69dc61e
Compare
69dc61e
to
d95f952
Compare
b775ccd
to
b4e1979
Compare
===== 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
b4e1979
to
74b477a
Compare
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, ?string $tableName, 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