Open konadave opened 1 year ago
Assume overrides are based on compatibility version in info.xml
Actually, if an extension has an override it should be making sure it's up to date with latest when it's released, so assume based on release date instead.
using a yet unresearched/unidentified method (maybe a github/lab api or exec-ing git), determine date of last modification in core, relative to installed version of CiviCRM, for each override...
function overrides_getAllReleases() {
$notes = file_get_contents('https://raw.githubusercontent.com/civicrm/civicrm-core/master/release-notes.md');
$versions = [];
preg_match_all('/^## CiviCRM (.+?)$/m', $notes, $versions);
$dates = [];
preg_match_all('/^Released (.+?)$/m', $notes, $dates);
return array_combine($versions[1], $dates[1]);
}
...will produce an array where the keys contain the version number and the values contain the release date back to 4.7.14. We can use the same base URL to download the correct files to compare with.
For example, let's say an extension released Jan 1st 2023 contains an override of CRM_Utils_System
. https://raw.githubusercontent.com/civicrm/civicrm-core/5.56.1/CRM/Utils/System.php
to determine what's been overridden by the extension, and https://raw.githubusercontent.com/civicrm/civicrm-core/master/CRM/Utils/System.php
to compare against latest to see if changes have since been made.
Downloading via raw avoids the need to create access tokens to use an API. This might be good enough, we'll see.
Just an FYI for the zero followers...
All the hope of preventing conflicting extensions from getting installed probably isn't worth the effort, it's too easy to bypass. One could install via cv
, or uninstall the overrides extension first, or remove the override initially to get it to install then add it back in or otherwise add an override after the fact.
The idea of reacting to install/enable/disable/uninstall and taking/saving diffs and whatnot is also unnecessary. It's going to do it's thing on demand; once a day as part of api.System.check (i.e. system status) and when directly accessing the overrides UI.
Automated communication with maintainer is also probably over the top. Will probably just provide a mailto: link to the maintainer somewhere.
A new 2.0 beta is about ready for testing. Much smarter and no direct initiation from user required. Will likely drop in a few days.
The main weakness of the current overrides extension is the fact that none of it is automatic. The person upgrading Civi needs to remember to take a snapshot before the upgrade so that it can detect changes properly. And then after the upgrade they have to go manually look to see if there were changes. Then deal with it. It should be easier. Here's my thinking on a 2.0 version of this extension.
On this extension install:
On other extension install/enable/upgrade:
On other extension uninstall/disable:
On Civi upgrade:
Extension UI:
Assume overrides are based on compatibility version in info.xml:
Notify maintainer when an override is changed in core:
Hooks and stuff:
hook_civicrm_pageRun/buildForm
to handle pre action checkshook_civicrm_postProcess
is not called, so need another way to detect extension changeshook_civicrm_post
called for entity == extension and action == delete during uninstall, but that's ithook_civicrm_postSave_civicrm_extension
is not calledapi.System.check
would be called after changes, triggeringhook_civicrm_check
, but nocivi.api.respond
can see3.extension.install
and3.extension.enable
, not sure yet about upgrade, but it does not see disable or uninstall. if upgrade is seen, this may be enough, however...cv
did not use the api so was not seenhook_civicrm_navigationMenu
in theory (i.e. I haven't tested yet) should be called after the status of an extension change, so it may be suitable as a trigger to identify overrides and their diffshook_civicrm_somethingUpgraded
that gets passed the key and current state would be nicer, assuming core team is open to minor changes in order to support thishook_civicrm_check
will provide the "conflicting overrides" and "core was updated" warnings for system status