-
-
Notifications
You must be signed in to change notification settings - Fork 821
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#2547 - Add base-upgrader to core #20090
Conversation
(Standard links)
|
629b2df
to
9562433
Compare
This piece was fairly easy to extract: #20091 |
@totten can you rebase now? |
9562433
to
294a0f7
Compare
Yep, thanks @seamuslee001. Rebased. |
…fications (w/top-sort)
This class is based on refactoring the civix template. Major sections have been split out into traits. This should make it more readable (and potentially make it easier to remix). This base-class should generally provide an equivalent DX for subclass authors: * Variables have the same names. * Most method signatures are identical (e.g. `executeFoo()`) * Some methods have been redeclared in equivalent form (`addTask()` - using splat instead `func_get_args()`). * Two internal functions have slightly diff signatures (`enqueuePendingRevisions()`, `_queueAdapter()``).
This is essentially a copy of CRM_Extension_Manager_ModuleTest, adapted to use the upgrader class instead of lifecycle-hooks.
294a0f7
to
cc26003
Compare
@seamuslee001 @eileenmcnaughton @colemanw - In terms of scoping this PR, I included the patches for (An alternative way to |
I did an |
Overview
Many extensions include an "upgrader" class, a "base upgrader" class, and some wiring to support them. This patch migrates a lot of that boilerplate to core and does some cleanup in the process.
As discussed in https://lab.civicrm.org/dev/core/-/issues/2547, this addresses a theme shared by a few other issues -- the old way of wiring-up lifecycle-hooks is problematic, and making a direct change is also problematic. We can resolve those with new wiring for the upgrader.
This change means that (going forward):
Before
Most extensions which define schema rely on
civix
's upgrader template. It defines these four elements:myext.php
: This has stubs forhook_install
,hook_uninstall
,hook_upgrade
, etc -- each delegates tomyext.civix.php
.myext.civix.php
: This has stubs forhook_install
,hook_uninstall
,hook_upgrade
, etc -- each delegates toCRM/Myext/Upgrader.php
.CRM/Myext/Upgrader.php
: This is the customizable list of install/uninstall/upgrade steps.CRM/Myext/Upgrader/Base.php
: This is a large boilerplate file. It has a library of helpers+adapters.After
Existing extensions may still work the same way.
Going forward, core extensions (and probably future civix-based extensions) should only define two elements:
info.xml
: Declare<upgrader>CRM_Myext_Upgrader</upgrader>
.CRM/Myext/Upgrader.php
: As before, this is the customizable list of install/uninstall/upgrade steps. It implements an interface (CRM_Extension_Upgrader_Interface
). For convenience, it can extend the base implementation (CRM_Extension_Upgrader_Base
) which matches the old boilerplate.For example:
And:
(There is an example of this in
tests/extensions/test.extension.manager.moduleupgtest
.)Comments
#19865 also aims to reduce civix boilerplate. However, it addresses a different aspect. #19865 provides a way to dedupe boilerplate for normal hooks (like
hook_xmlMenu
). This PR deals with the abnormal hooks (likehook_install
).I think a primary question for this PR is: what kind of QA tasks are appropriate before merging?