konadave / com.klangsoft.overrides

Other
4 stars 4 forks source link

Potential 2.0 version discussion #6

Open konadave opened 1 year ago

konadave commented 1 year ago

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:

konadave commented 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.

konadave commented 1 year ago

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.