From c14e4888faa2852efb7484da334afd1e51f9ab13 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 14 Sep 2020 00:34:35 -0700 Subject: [PATCH] greenwich - Activate during upgrade --- CRM/Upgrade/Incremental/php/FiveThirtyOne.php | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FiveThirtyOne.php b/CRM/Upgrade/Incremental/php/FiveThirtyOne.php index 0f4ba135eb..2833c33e76 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirtyOne.php +++ b/CRM/Upgrade/Incremental/php/FiveThirtyOne.php @@ -52,19 +52,6 @@ class CRM_Upgrade_Incremental_php_FiveThirtyOne extends CRM_Upgrade_Incremental_ * (change the x in the function name): */ - // /** - // * Upgrade function. - // * - // * @param string $rev - // */ - // public function upgrade_5_0_x($rev) { - // $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - // $this->addTask('Do the foo change', 'taskFoo', ...); - // // Additional tasks here... - // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex. - // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. - // } - /** * Upgrade function. * @@ -74,6 +61,7 @@ class CRM_Upgrade_Incremental_php_FiveThirtyOne extends CRM_Upgrade_Incremental_ $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); $this->addTask('Remove Eway Single Currency Payment Processor type if not used or install the new extension for it', 'enableEwaySingleExtension'); $this->addTask('dev/core#1486 Remove FKs from ACL Cache tables', 'removeFKsFromACLCacheTables'); + $this->addTask('Activate core extension "Greenwich"', 'installGreenwich'); } public static function enableEwaySingleExtension(CRM_Queue_TaskContext $ctx) { @@ -114,4 +102,35 @@ class CRM_Upgrade_Incremental_php_FiveThirtyOne extends CRM_Upgrade_Incremental_ return TRUE; } + /** + * Install greenwich extensions. + * + * This feature is restructured as a core extension - which is primarily a code cleanup step. + * + * @param \CRM_Queue_TaskContext $ctx + * + * @return bool + * + * @throws \CRM_Core_Exception + */ + public static function installGreenwich(CRM_Queue_TaskContext $ctx) { + // Install via direct SQL manipulation. Note that: + // (1) This extension has no activation logic. + // (2) On new installs, the extension is activated purely via default SQL INSERT. + // (3) Caches are flushed at the end of the upgrade. + // ($) Over long term, upgrade steps are more reliable in SQL. API/BAO sometimes don't work mid-upgrade. + $insert = CRM_Utils_SQL_Insert::into('civicrm_extension')->row([ + 'type' => 'module', + 'full_name' => 'greenwich', + 'name' => 'Theme: Greenwich', + 'label' => 'Theme: Greenwich', + 'file' => 'greenwich', + 'schema_version' => NULL, + 'is_active' => 1, + ]); + CRM_Core_DAO::executeQuery($insert->usingReplace()->toSQL()); + + return TRUE; + } + } -- 2.25.1