Skip to content

Commit

Permalink
Merge pull request #17534 from eileenmcnaughton/fatal2
Browse files Browse the repository at this point in the history
Remove instances of fatal from upgrade folder
  • Loading branch information
eileenmcnaughton authored Jun 7, 2020
2 parents 74db8d6 + 800dad4 commit 0a83e29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions CRM/Upgrade/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function preProcess() {
if (!isset($errorMessage)) {
$errorMessage = 'pre-condition failed for current upgrade step';
}
CRM_Core_Error::fatal($errorMessage);
throw new CRM_Core_Exception($errorMessage);
}
$this->assign('recentlyViewed', FALSE);
}
Expand Down Expand Up @@ -234,7 +234,7 @@ public function postProcess() {
if (!isset($errorMessage)) {
$errorMessage = 'post-condition failed for current upgrade step';
}
CRM_Core_Error::fatal($errorMessage);
throw new CRM_Core_Exception($errorMessage);
}
}

Expand Down Expand Up @@ -385,7 +385,7 @@ public function processSQL($rev) {
}
else {
if (!file_exists($sqlFile)) {
CRM_Core_Error::fatal("sqlfile - $rev.mysql not found.");
throw new CRM_Core_Exception("sqlfile - $rev.mysql not found.");
}
$this->source($sqlFile);
}
Expand All @@ -400,13 +400,13 @@ public function getUpgradeVersions() {
$latestVer = CRM_Utils_System::version();
$currentVer = CRM_Core_BAO_Domain::version(TRUE);
if (!$currentVer) {
CRM_Core_Error::fatal(ts('Version information missing in civicrm database.'));
throw new CRM_Core_Exception(ts('Version information missing in civicrm database.'));
}
elseif (stripos($currentVer, 'upgrade')) {
CRM_Core_Error::fatal(ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again.'));
throw new CRM_Core_Exception(ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again.'));
}
if (!$latestVer) {
CRM_Core_Error::fatal(ts('Version information missing in civicrm codebase.'));
throw new CRM_Core_Exception(ts('Version information missing in civicrm codebase.'));
}

return [$currentVer, $latestVer];
Expand Down Expand Up @@ -510,7 +510,7 @@ public static function buildQueue($currentVer, $latestVer, $postUpgradeMessageFi

// Ensure that queue can be created
if (!CRM_Queue_BAO_QueueItem::findCreateTable()) {
CRM_Core_Error::fatal(ts('Failed to find or create queueing table'));
throw new CRM_Core_Exception(ts('Failed to find or create queueing table'));
}
$queue = CRM_Queue_Service::singleton()->create([
'name' => self::QUEUE_NAME,
Expand Down Expand Up @@ -707,15 +707,15 @@ public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext $ctx, $rev
// pre-db check for major release.
if ($upgrade->checkVersionRelease($rev, 'alpha1')) {
if (!(is_callable([$versionObject, 'verifyPreDBstate']))) {
CRM_Core_Error::fatal("verifyPreDBstate method was not found for $rev");
throw new CRM_Core_Exception("verifyPreDBstate method was not found for $rev");
}

$error = NULL;
if (!($versionObject->verifyPreDBstate($error))) {
if (!isset($error)) {
$error = "post-condition failed for current upgrade for $rev";
}
CRM_Core_Error::fatal($error);
throw new CRM_Core_Exception($error);
}

}
Expand Down
6 changes: 3 additions & 3 deletions CRM/Upgrade/Incremental/php/FourThree.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU
1 => $count,
2 => '<em>SELECT ct.* FROM civicrm_contribution ct LEFT JOIN civicrm_contact c ON ct.contact_id = c.id WHERE c.id IS NULL;</em>',
]);
CRM_Core_Error::fatal($error);
throw new CRM_Core_Exception($error);
return FALSE;
}
}
Expand All @@ -51,7 +51,7 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU
theme('item_list', []);
$theme_registry = theme_get_registry();
if (!isset($theme_registry['page']['preprocess functions']) || FALSE === array_search('civicrm_preprocess_page_inject', $theme_registry['page']['preprocess functions'])) {
CRM_Core_Error::fatal('Please reset the Drupal cache (Administer => Site Configuration => Performance => Clear cached data))');
throw new CRM_Core_Exception('Please reset the Drupal cache (Administer => Site Configuration => Performance => Clear cached data))');
}
}
}
Expand Down Expand Up @@ -79,7 +79,7 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU
$dao = CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE);
if ($dao->N) {
$invalidDataMessage = '<strong>Oops, it looks like you have orphaned recurring contribution records in your database. Before this upgrade can complete they will need to be fixed or deleted. <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Orphaned+Contribution+Recur+Records" target="_blank">You can review steps to correct this situation on the documentation wiki.</a></strong>';
CRM_Core_Error::fatal($invalidDataMessage);
throw new CRM_Core_Exception($invalidDataMessage);
return FALSE;
}
}
Expand Down
10 changes: 5 additions & 5 deletions CRM/Upgrade/Page/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function run() {
break;

default:
CRM_Core_Error::fatal(ts('Unrecognized upgrade action'));
throw new CRM_Core_Exception(ts('Unrecognized upgrade action'));
}
}

Expand All @@ -79,7 +79,7 @@ public function runIntro() {
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();

if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
CRM_Core_Error::fatal($error);
throw new CRM_Core_Exception($error);
}

$config = CRM_Core_Config::singleton();
Expand Down Expand Up @@ -119,7 +119,7 @@ public function runBegin() {
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();

if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
CRM_Core_Error::fatal($error);
throw new CRM_Core_Exception($error);
}

$config = CRM_Core_Config::singleton();
Expand All @@ -145,7 +145,7 @@ public function runBegin() {
'buttons' => ['retry' => $config->debug, 'skip' => $config->debug],
]);
$queueRunner->runAllViaWeb();
CRM_Core_Error::fatal(ts('Upgrade failed to redirect'));
throw new CRM_Core_Exception(ts('Upgrade failed to redirect'));
}

/**
Expand All @@ -172,7 +172,7 @@ public function runFinish() {
// do a version check - after doFinish() sets the final version
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
if ($error = $upgrade->checkCurrentVersion($currentVer, $latestVer)) {
CRM_Core_Error::fatal($error);
throw new CRM_Core_Exception($error);
}

$template->assign('message', $postUpgradeMessage);
Expand Down

0 comments on commit 0a83e29

Please sign in to comment.