[Ref] Remove some instances of fatal in BAO classes
authoreileen <emcnaughton@wikimedia.org>
Sun, 7 Jun 2020 05:24:03 +0000 (17:24 +1200)
committereileen <emcnaughton@wikimedia.org>
Sun, 7 Jun 2020 05:24:03 +0000 (17:24 +1200)
CRM/Batch/BAO/Batch.php
CRM/Campaign/BAO/Petition.php
CRM/Cxn/CiviCxnHttp.php
CRM/Financial/BAO/PaymentProcessor.php
CRM/Financial/BAO/PaymentProcessorType.php
CRM/Member/BAO/Membership.php
CRM/Utils/HttpClient.php

index f44c0e4999485fcd03a7a35621bd2bd1ba4e9a9c..3bb93f140b70980255282f987bf5c2a0d85476ec 100644 (file)
@@ -579,12 +579,10 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
    */
   public static function exportFinancialBatch($batchIds, $exportFormat, $downloadFile) {
     if (empty($batchIds)) {
-      CRM_Core_Error::fatal(ts('No batches were selected.'));
-      return;
+      throw new CRM_Core_Exception(ts('No batches were selected.'));
     }
     if (empty($exportFormat)) {
-      CRM_Core_Error::fatal(ts('No export format selected.'));
-      return;
+      throw new CRM_Core_Exception(ts('No export format selected.'));
     }
     self::$_exportFormat = $exportFormat;
 
@@ -594,7 +592,7 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
       $exporter = new $exporterClass();
     }
     else {
-      CRM_Core_Error::fatal("Could not locate exporter: $exporterClass");
+      throw new CRM_Core_Exception("Could not locate exporter: $exporterClass");
     }
     $export = [];
     $exporter->_isDownloadFile = $downloadFile;
index 406b38f70f8bf4c70ff52a8671bf0b3608b1804b..72e2151a640f88cd0311b723df4243efee7a7227 100644 (file)
@@ -266,8 +266,7 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
       return TRUE;
     }
     else {
-      CRM_Core_Error::fatal(ts('Petition Id and/or Activity Id is not of the type Positive.'));
-      return FALSE;
+      throw new CRM_Core_Exception(ts('Petition Id and/or Activity Id is not of the type Positive.'));
     }
   }
 
@@ -561,7 +560,7 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
     $petitionInfo = [];
     CRM_Campaign_BAO_Survey::retrieve($petitionParams, $petitionInfo);
     if (empty($petitionInfo)) {
-      CRM_Core_Error::fatal('Petition doesn\'t exist.');
+      throw new CRM_Core_Exception('Petition doesn\'t exist.');
     }
 
     //get the default domain email address.
index a972c7fd35d24b6f7128338d0440d06faf945df2..17aa4fb549c83f47b9df08c2c440bbd54e781cbd 100644 (file)
@@ -107,7 +107,7 @@ class CRM_Cxn_CiviCxnHttp extends \Civi\Cxn\Rpc\Http\PhpHttp {
       $result['ssl'] = $caConfig->toStreamOptions();
     }
     if (!$caConfig->isEnableSSL() && preg_match('/^https:/', $url)) {
-      CRM_Core_Error::fatal('Cannot fetch document - system does not support SSL');
+      throw new CRM_Core_Exception('Cannot fetch document - system does not support SSL');
     }
 
     return $result;
index 363828f31a76c00e5cccfd25461cc12b733f17af..ed37743c5ab4fb746e0b9e90a52ba28fc4208435 100644 (file)
@@ -49,7 +49,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
       $ppTypeDAO = new CRM_Financial_DAO_PaymentProcessorType();
       $ppTypeDAO->id = $params['payment_processor_type_id'];
       if (!$ppTypeDAO->find(TRUE)) {
-        CRM_Core_Error::fatal(ts('Could not find payment processor meta information'));
+        throw new CRM_Core_Exception(ts('Could not find payment processor meta information'));
       }
 
       // also copy meta fields from the info DAO
@@ -194,7 +194,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    */
   public static function del($paymentProcessorID) {
     if (!$paymentProcessorID) {
-      CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
+      throw new CRM_Core_Exception(ts('Invalid value passed to delete function.'));
     }
 
     $dao = new CRM_Financial_DAO_PaymentProcessor();
index e64fb29713d1a2f6adc0359301550259544bfbc6..c0f49c2b10bfe17b862267e198c496bdba872347 100644 (file)
@@ -141,7 +141,7 @@ class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentPr
       $ppByName = self::getAllPaymentProcessorTypes('name');
       if (array_key_exists($paymentProcessorType->name, $ppByName)) {
         if ($ppByName[$paymentProcessorType->name] != $paymentProcessorType->id) {
-          CRM_Core_Error::fatal('This payment processor type already exists.');
+          throw new CRM_Core_Exception('This payment processor type already exists.');
         }
       }
     }
index df5e17a48d3cd6e45c4d338f5531315dd2cc3a96..03961d953e69cd6b4628568f9829a9dd703888e6 100644 (file)
@@ -1062,7 +1062,7 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
    */
   public static function getMembershipCount($membershipTypeId, $date = NULL, $isTest = 0, $isOwner = 0) {
     if (!CRM_Utils_Rule::date($date)) {
-      CRM_Core_Error::fatal(ts('Invalid date "%1" (must have form yyyy-mm-dd).', [1 => $date]));
+      throw new CRM_Core_Exception(ts('Invalid date "%1" (must have form yyyy-mm-dd).', [1 => $date]));
     }
 
     $params = [
index c7989ec626842d935c381ed23a99e1107a0fee46..c2d12ae18cffc677d923bd78b7b1c62a78147289 100644 (file)
@@ -117,7 +117,6 @@ class CRM_Utils_HttpClient {
     list($ch, $caConfig) = $this->createCurl($remoteFile);
 
     if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) {
-      // CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
       return [self::STATUS_DL_ERROR, NULL];
     }
 
@@ -146,14 +145,12 @@ class CRM_Utils_HttpClient {
   public function post($remoteFile, $params) {
     // Download extension zip file ...
     if (!function_exists('curl_init')) {
-      //CRM_Core_Error::fatal('Cannot install this extension - curl is not installed!');
       return [self::STATUS_DL_ERROR, NULL];
     }
 
     list($ch, $caConfig) = $this->createCurl($remoteFile);
 
     if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) {
-      // CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
       return [self::STATUS_DL_ERROR, NULL];
     }