From 8057f34ab93270f27806643a53210a4705344618 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 1 Jun 2022 14:10:22 -0700 Subject: [PATCH] Upgrader - Enqueue extension upgrade tasks --- CRM/Upgrade/Form.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CRM/Upgrade/Form.php b/CRM/Upgrade/Form.php index 051a259164..9bd995ffa1 100644 --- a/CRM/Upgrade/Form.php +++ b/CRM/Upgrade/Form.php @@ -599,6 +599,14 @@ SET version = '$version' ); $queue->createItem($task, ['weight' => 1000]); + $task = new CRM_Queue_Task( + ['CRM_Upgrade_Form', 'enqueueExtUpgrades'], + [$rev, $latestVer, $latestVer, $postUpgradeMessageFile], + "Assess extension upgrades" + ); + // This places the extension-upgrades after `doCoreFinish` - but before new extensions (`addExtensionTask()`) + $queue->createItem($task, ['weight' => 1500]); + return $queue; } @@ -831,6 +839,23 @@ SET version = '$version' return TRUE; } + /** + * After core schema is up-to-date, ensure that + * @param \CRM_Queue_TaskContext $ctx + * @return bool + */ + public static function enqueueExtUpgrades(CRM_Queue_TaskContext $ctx): bool { + CRM_Core_Config::singleton(TRUE, TRUE); + CRM_Upgrade_DispatchPolicy::assertActive('upgrade.finish'); + if (CRM_Extension_Upgrades::hasPending()) { + CRM_Extension_Upgrades::fillQueue($ctx->queue); + // ISSUE: Core-upgrade tasks and ext-upgrade tasks need to run with different `DispatchPolicy`s + // (`upgrade.main` vs `upgrade.finish` or `NULL`). + // Can we make policy transitions sticky -- eg maybe a setting or session-variable? + } + return TRUE; + } + /** * After finishing the queue, the upgrade-runner calls `doFinish()`. * -- 2.25.1