4

Question: When upgrading an extension from the UI on Site A it will update the files and run the update hook. How do I manually execute the update hook for the extension on the other Site B, C, etc?

The extension directory on our server is shared between all the sites. This means that when I "upgrade" an extension on Site A the files will be updated for all the sites. However, the "update" hook is only executed on Site A. The result is that the extension files are up-to-date for ALL sites and CiviCRM perceives that Site B, C, etc no longer need to update the extension. This means that I cannot execute any update functions. Is there a way to manually trigger the update function?

Configuration Information:

  • CiviCRM 5.8
  • Drupal 7
  • Each of our sites has a separate database (they are not shared).
  • Each site is configured in drupal_root/sites/subdomain.domain.org
  • Extensions are installed in a directory shared by all sites (drupal_root/CustomExtensions).
  • Do you mean an uprade from the extension menu (a new version) or the extension upgrades notice? (the little alert box in the top right hand corner when you do Administer>Sytem Settings>Extensions? – ErikH - CiviCooP Dec 11 '18 at 15:05
  • 1
    I am talking about an upgrade from the extensions page to a new version of an extension. The URL I use is: /civicrm/admin/extensions?reset=1 My scenario would also apply to extensions that I pull from Git. I am curious how to initiate the update hook for those as well. – Sleewok Dec 11 '18 at 17:02
  • 1
    I am not clear why you would need the update to be flagged in that way? Do you just want a reminder that there is a new version? But you already know that from your first site? After that you can upgrade "manually" if you want to? – ErikH - CiviCooP Dec 11 '18 at 17:10
  • 1
    Here is how I perceive the update happening. When I click "update" for a particular extension while on the SITE A extension page it will download the new version (which therefore updates the FILES for ALL the sites that share that extension directory). The update process triggers the update hook ONLY on SITE A. Therein lies the problem. Once the files are updated, CiviCRM no longer sees the need to update. I no longer have the option to run "update" on Site B, C, etc. So while the files are up-to-date on all sites, any necessary updates are not run on the other sites. Thanks for your patience! – Sleewok Dec 11 '18 at 19:09
  • 1
    I see where a lot of the confusion was coming from. I updated my initial question to hopefully make it more clear. I never should have used the term "notification". Sorry about that! – Sleewok Dec 11 '18 at 19:15
1

How about make a backup of the extension folder before the first update, then do on site A, then restore the backup folder, then do site B, etc...

1

I think there are 2 steps when upgrading an extension:

  1. upgrade the extension itself (replacing the old version of the files with the new version) . This is done when you hit the upgrade link in the overview of the extensions. That can easily be done manually by downloading the new extension folder and replacing the existing folder in your extension folder
  2. Executing the extension upgrade actions that are triggered by the functions in the Upgrader class. These are the cases where after installing a new version you get the notice in the top right corner when you navigate to Administer>System Settings>Extensions. There are based on the current value of the column schema_version in the table civicrm_extensions. As your sites have different databases but share the extensions folder this might get a little confusing. I would check what happens with the files in the different databases, it might be that the schema_version gets updated in all your databases. If that is the case you could set the column to the previous version in the DB, that should trigger the extension update function?
  • When comparing most of the other DBs, the schema_version is actually NULL for most rows. In fact it is NULL for most extensions, even on the DB that an upgrade/install was originally performed. Any ideas why that might be? – Sleewok Dec 17 '18 at 15:26
  • 1
    The version you see here is NOT about the version of the extension but the version number that is used in the upgrade function of the extension Upgrader class (check docs.civicrm.org/dev/en/latest/extensions/civix/…). So if I want to perform some actions on upgrade like update a table I would for example add a function upgrade_1005() and once you have executed that extension update (in the right top corner, NOT install the latest code) the schema_version in the DB will be 1005. – ErikH - CiviCooP Dec 17 '18 at 15:51
0

The extension upgrade command can be executed using API (version 3).

Drush can then be used to execute the command on multiple sites:

drush cvapi Extension.upgrade reset=1 

A refresh may be necessary

drush cvapi Extension.refresh 

Can anyone else verify this works for extension upgrades that require an update?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.