Skip to content

Commit

Permalink
[REF] Add in function to retrieve Pre Upgrade messages in headless
Browse files Browse the repository at this point in the history
  • Loading branch information
seamuslee001 committed Jan 25, 2023
1 parent df824be commit cf65833
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions CRM/Upgrade/Headless.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
*/
class CRM_Upgrade_Headless {

/**
* Pre Upgrade Message
* @var string
*/
private $preUpgradeMessage;

/**
* Perform an upgrade without using the web-frontend
*
Expand All @@ -38,8 +44,11 @@ public function run($enablePrint = TRUE) {
CRM_Core_DAO::dropTriggers();

// CRM-11156
$preUpgradeMessage = NULL;
$upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
if (empty($this->preUpgradeMessage)) {
$preUpgradeMessage = NULL;
$upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
$this->preUpgradeMessage = $preUpgradeMessage();
}

$postUpgradeMessageFile = CRM_Utils_File::tempnam('civicrm-post-upgrade');
$queueRunner = new CRM_Queue_Runner([
Expand Down Expand Up @@ -67,4 +76,25 @@ public function run($enablePrint = TRUE) {
];
}

/**
* Get the PreUpgrade message
* @return string
* @throws \Exception
*/
public function getPreUpgradeMessage(): string {
$upgrade = new CRM_Upgrade_Form();
[$currentVer, $latestVer] = $upgrade->getUpgradeVersions();

if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
throw new Exception($error);
}
// CRM-11156
if (empty($this->preUpgradeMessage)) {
$preUpgradeMessage = NULL;
$upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
$this->preUpgradeMessage = $preUpgradeMessage();
}
return $this->preUpgradeMessage;
}

}

0 comments on commit cf65833

Please sign in to comment.