Skip to content

Instantly share code, notes, and snippets.

@totten
Last active April 2, 2020 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save totten/96aa7172faced3fde2225e145307f3b9 to your computer and use it in GitHub Desktop.
Save totten/96aa7172faced3fde2225e145307f3b9 to your computer and use it in GitHub Desktop.
5.24 Upgrade - Debugging `sequentialcreditnotes`

These patches might help with diagnosing problems in the upgrade step, "Install sequential creditnote extension".

The following two are alternatives:

  • installViaManager.patch - This bypasses the civicrm_api() wrapper which sometimes interferes with debugging.
  • installViaSql.patch - This reduces the installation steps to the fewest possible layers.
diff --git a/CRM/Upgrade/Incremental/php/FiveTwentyFour.php b/CRM/Upgrade/Incremental/php/FiveTwentyFour.php
index 1b90c51619..bc84ab1727 100644
--- a/CRM/Upgrade/Incremental/php/FiveTwentyFour.php
+++ b/CRM/Upgrade/Incremental/php/FiveTwentyFour.php
@@ -75,7 +75,9 @@ class CRM_Upgrade_Incremental_php_FiveTwentyFour extends CRM_Upgrade_Incremental
* @throws \CiviCRM_API3_Exception
*/
public static function installCreditNotes(CRM_Queue_TaskContext $ctx) {
- civicrm_api3('Extension', 'install', ['keys' => 'sequentialcreditnotes']);
+ $manager = CRM_Extension_System::singleton()->getManager();
+ $manager->install($manager->findInstallRequirements(['sequentialcreditnotes']));
return TRUE;
}
diff --git a/CRM/Upgrade/Incremental/php/FiveTwentyFour.php b/CRM/Upgrade/Incremental/php/FiveTwentyFour.php
index 1b90c51619..abbc12fe91 100644
--- a/CRM/Upgrade/Incremental/php/FiveTwentyFour.php
+++ b/CRM/Upgrade/Incremental/php/FiveTwentyFour.php
@@ -75,7 +75,18 @@ class CRM_Upgrade_Incremental_php_FiveTwentyFour extends CRM_Upgrade_Incremental
* @throws \CiviCRM_API3_Exception
*/
public static function installCreditNotes(CRM_Queue_TaskContext $ctx) {
- civicrm_api3('Extension', 'install', ['keys' => 'sequentialcreditnotes']);
+ // This extension has no activation logic, and caches are flushed at the end of the ugprade. Using SQL may be functional enough.
+ // Also, over long term, upgrade steps can be persnickity about using APIs/BAOs/DAOs.
+ $insert = CRM_Utils_SQL_Insert::into('civicrm_extension')->row([
+ 'type' => 'module',
+ 'full_name' => 'sequentialcreditnotes',
+ 'name' => 'Sequential credit notes',
+ 'label' => 'Sequential credit notes',
+ 'file' => 'sequentialcreditnotes',
+ 'schema_version' => NULL,
+ 'is_active' => 1,
+ ]);
+ CRM_Core_DAO::executeQuery($insert->usingReplace()->toSQL());
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment