From 79e11805a6eee1c09afd388eccdf0411850f4b25 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 8 Jun 2020 11:13:26 +1000 Subject: [PATCH] dev/core#560 Convert final CRM_Core_Error::fatal to statusBounces or Exceptions --- CRM/Activity/BAO/Activity.php | 3 +-- CRM/Activity/Import/Parser.php | 2 +- CRM/Contact/BAO/Query.php | 6 +++--- CRM/Contribute/BAO/Contribution.php | 2 +- CRM/Core/Controller.php | 2 +- CRM/Core/IDS.php | 2 +- CRM/Core/JobManager.php | 2 +- CRM/Core/Page/AJAX.php | 2 +- CRM/Core/Page/Redirect.php | 2 +- CRM/Core/Permission.php | 2 +- CRM/Core/Region.php | 4 ++-- CRM/Core/Selector/Base.php | 3 --- CRM/Custom/Form/ChangeFieldType.php | 2 +- CRM/Custom/Form/Field.php | 2 +- CRM/Custom/Form/Option.php | 2 +- CRM/Custom/Import/Parser.php | 2 +- CRM/Custom/Page/Field.php | 2 +- CRM/Custom/Page/Option.php | 2 +- CRM/Event/BAO/Participant.php | 2 +- CRM/Event/BAO/ParticipantPayment.php | 2 +- CRM/Event/Cart/BAO/Cart.php | 4 ++-- CRM/Event/Cart/BAO/EventInCart.php | 2 +- CRM/Event/Form/ManageEvent/Repeat.php | 2 +- CRM/Event/Form/ManageEvent/TabHeader.php | 2 +- CRM/Event/Form/Registration.php | 2 +- CRM/Event/Import/Parser.php | 2 +- CRM/Event/Page/ParticipantListing.php | 4 ++-- CRM/Financial/Page/FinancialTypeAccount.php | 3 +-- CRM/Member/Form/Task/Batch.php | 2 +- CRM/Member/Import/Parser.php | 2 +- CRM/Member/Page/DashBoard.php | 2 +- CRM/PCP/BAO/PCP.php | 4 ++-- CRM/PCP/Form/Campaign.php | 2 +- CRM/PCP/Form/PCPAccount.php | 4 ++-- CRM/Price/Form/Option.php | 2 +- CRM/Profile/Form.php | 10 +++++----- CRM/Profile/Page/Dynamic.php | 2 +- CRM/Profile/Page/Listings.php | 4 ++-- CRM/Profile/Page/View.php | 4 ++-- CRM/Queue/Page/Runner.php | 2 +- CRM/Queue/Queue/Sql.php | 2 +- CRM/UF/Page/ProfileEditor.php | 2 +- 42 files changed, 54 insertions(+), 59 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 1efa820244..68282aee31 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -1770,8 +1770,7 @@ WHERE activity.id IN ($activityIds)"; // @todo - use api - remove lots of wrangling above. Remove deprecated fatal & let form layer // deal with any exceptions. if (is_a(self::create($activityParams), 'CRM_Core_Error')) { - CRM_Core_Error::fatal("Failed creating Activity for $component of id {$activity->id}"); - return FALSE; + throw new CRM_Core_Exception("Failed creating Activity for $component of id {$activity->id}"); } } diff --git a/CRM/Activity/Import/Parser.php b/CRM/Activity/Import/Parser.php index b3b5871aff..d74f955ca0 100644 --- a/CRM/Activity/Import/Parser.php +++ b/CRM/Activity/Import/Parser.php @@ -67,7 +67,7 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { $totalRowCount = NULL ) { if (!is_array($fileName)) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to determine import file'); } $fileName = $fileName['name']; diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 694f6a84d4..6e74c02f18 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -2323,7 +2323,7 @@ class CRM_Contact_BAO_Query { } // we don't know when this might happen else { - CRM_Core_Error::fatal(ts("%1 is not a valid operator", [1 => $operator])); + throw new CRM_Core_Exception(ts("%1 is not a valid operator", [1 => $operator])); } } } @@ -2417,7 +2417,7 @@ class CRM_Contact_BAO_Query { $tName = str_replace(' ', '_', $tName); return [$tName, $fldName]; } - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Cannot determine location table information'); } /** @@ -2973,7 +2973,7 @@ class CRM_Contact_BAO_Query { if (is_array($value) && count($value) > 1) { if (strpos($op, 'IN') === FALSE && strpos($op, 'NULL') === FALSE) { - CRM_Core_Error::fatal(ts("%1 is not a valid operator", [1 => $op])); + throw new CRM_Core_Exception(ts("%1 is not a valid operator", [1 => $op])); } $this->_useDistinct = TRUE; } diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 6ad09931c8..1050193219 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2115,7 +2115,7 @@ LEFT JOIN civicrm_contribution contribution ON ( componentPayment.contribution_ $ids['contributionPage'] = NULL; if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to validate supplied data'); } $memberships = &$objects['membership']; diff --git a/CRM/Core/Controller.php b/CRM/Core/Controller.php index 0550fb39f3..5f4baed935 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -814,7 +814,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { public function invalidKeyCommon() { $msg = ts("We can't load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site administrator for assistance.") . '

' . ts('Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.') . '

' . ts('Error type: Could not find a valid session key.'); - CRM_Core_Error::fatal($msg); + throw new CRM_Core_Exception($msg); } /** diff --git a/CRM/Core/IDS.php b/CRM/Core/IDS.php index 7a3eded15a..5401ea8117 100644 --- a/CRM/Core/IDS.php +++ b/CRM/Core/IDS.php @@ -292,7 +292,7 @@ class CRM_Core_IDS { ); CRM_Utils_JSON::output($error); } - CRM_Core_Error::fatal($msg); + throw new CRM_Core_Exception($msg); } } diff --git a/CRM/Core/JobManager.php b/CRM/Core/JobManager.php index ed2954fc1d..d19e786d4a 100644 --- a/CRM/Core/JobManager.php +++ b/CRM/Core/JobManager.php @@ -181,7 +181,7 @@ class CRM_Core_JobManager { */ private function _getJob($id = NULL, $entity = NULL, $action = NULL) { if (is_null($id) && is_null($action)) { - CRM_Core_Error::fatal('You need to provide either id or name to use this method'); + throw new CRM_Core_Exception('You need to provide either id or name to use this method'); } $dao = new CRM_Core_DAO_Job(); $dao->id = $id; diff --git a/CRM/Core/Page/AJAX.php b/CRM/Core/Page/AJAX.php index 32dcbffba9..ccbcd67251 100644 --- a/CRM/Core/Page/AJAX.php +++ b/CRM/Core/Page/AJAX.php @@ -34,7 +34,7 @@ class CRM_Core_Page_AJAX { } if (!$className) { - CRM_Core_Error::fatal(ts('Invalid className: %1', [1 => $className])); + throw new CRM_Core_Exception(ts('Invalid className: %1', [1 => $className])); } $fnName = NULL; diff --git a/CRM/Core/Page/Redirect.php b/CRM/Core/Page/Redirect.php index 15141ae4f0..ed855d1df0 100644 --- a/CRM/Core/Page/Redirect.php +++ b/CRM/Core/Page/Redirect.php @@ -38,7 +38,7 @@ class CRM_Core_Page_Redirect extends CRM_Core_Page { */ public static function createUrl($requestPath, $requestArgs, $pageArgs, $absolute) { if (empty($pageArgs['url'])) { - CRM_Core_Error::fatal('This page is configured as a redirect, but it does not have a target.'); + CRM_Core_Error::statusBounce('This page is configured as a redirect, but it does not have a target.'); } $vars = []; diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index 08c978af38..2c71a406de 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -508,7 +508,7 @@ class CRM_Core_Permission { public static function checkMenuItem(&$item) { if (!array_key_exists('access_callback', $item)) { CRM_Core_Error::backtrace(); - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Missing Access Callback key in menu item'); } // if component_id is present, ensure it is enabled diff --git a/CRM/Core/Region.php b/CRM/Core/Region.php index 5d101d1d70..242387ca65 100644 --- a/CRM/Core/Region.php +++ b/CRM/Core/Region.php @@ -223,8 +223,8 @@ class CRM_Core_Region { break; default: - require_once 'CRM/Core/Error.php'; - CRM_Core_Error::fatal(ts('Snippet type %1 is unrecognized', + require_once 'CRM/Core/Exception.php'; + throw new CRM_Core_Exception(ts('Snippet type %1 is unrecognized', [1 => $snippet['type']])); } } diff --git a/CRM/Core/Selector/Base.php b/CRM/Core/Selector/Base.php index e80d6fcd3e..268f0e5842 100644 --- a/CRM/Core/Selector/Base.php +++ b/CRM/Core/Selector/Base.php @@ -123,9 +123,6 @@ class CRM_Core_Selector_Base { unset($header); } } - if ($firstElementNotFound) { - // CRM_Core_Error::fatal( "Could not find a valid sort directional element" ); - } } return $this->_order; } diff --git a/CRM/Custom/Form/ChangeFieldType.php b/CRM/Custom/Form/ChangeFieldType.php index c26c5c04f5..90d87917ed 100644 --- a/CRM/Custom/Form/ChangeFieldType.php +++ b/CRM/Custom/Form/ChangeFieldType.php @@ -61,7 +61,7 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { ); if (empty($this->_values) || empty($this->_htmlTypeTransitions)) { - CRM_Core_Error::fatal(ts("Invalid custom field or can't change input type of this custom field.")); + CRM_Core_Error::statusBounce(ts("Invalid custom field or can't change input type of this custom field.")); } $url = CRM_Utils_System::url('civicrm/admin/custom/group/field/update', diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index e61d23ed80..b7597bfe5f 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -121,7 +121,7 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { } if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) { - CRM_Core_Error::fatal("You cannot add or edit fields in a reserved custom field-set."); + CRM_Core_Error::statusBounce("You cannot add or edit fields in a reserved custom field-set."); } if ($this->_gid) { diff --git a/CRM/Custom/Form/Option.php b/CRM/Custom/Form/Option.php index 14e7b509e1..5a0c3d5eb3 100644 --- a/CRM/Custom/Form/Option.php +++ b/CRM/Custom/Form/Option.php @@ -76,7 +76,7 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { } if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) { - CRM_Core_Error::fatal("You cannot add or edit muliple choice options in a reserved custom field-set."); + CRM_Core_Error::statusBounce("You cannot add or edit muliple choice options in a reserved custom field-set."); } $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); diff --git a/CRM/Custom/Import/Parser.php b/CRM/Custom/Import/Parser.php index 09b3258a5e..c71018bb79 100644 --- a/CRM/Custom/Import/Parser.php +++ b/CRM/Custom/Import/Parser.php @@ -68,7 +68,7 @@ abstract class CRM_Custom_Import_Parser extends CRM_Contact_Import_Parser { $onDuplicate = self::DUPLICATE_SKIP ) { if (!is_array($fileName)) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to determine import file'); } $fileName = $fileName['name']; diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 708b342a24..d10a73dfa3 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -226,7 +226,7 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { } if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) { - CRM_Core_Error::fatal("You cannot add or edit fields in a reserved custom field-set."); + CRM_Core_Error::statusBounce("You cannot add or edit fields in a reserved custom field-set."); } $action = CRM_Utils_Request::retrieve('action', 'String', diff --git a/CRM/Custom/Page/Option.php b/CRM/Custom/Page/Option.php index a932fd36a5..7c409c7d78 100644 --- a/CRM/Custom/Page/Option.php +++ b/CRM/Custom/Page/Option.php @@ -213,7 +213,7 @@ WHERE option_group_id = %1"; ); if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) { - CRM_Core_Error::fatal("You cannot add or edit multiple choice options in a reserved custom field-set."); + CRM_Core_Error::statusBounce("You cannot add or edit multiple choice options in a reserved custom field-set."); } $optionGroupId = $this->getOptionGroupId($this->_fid); diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 64b2f806ce..d05b01176d 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1496,7 +1496,7 @@ UPDATE civicrm_participant ]; if (is_a(CRM_Activity_BAO_Activity::create($activityParams), 'CRM_Core_Error')) { - CRM_Core_Error::fatal('Failed creating Activity for expiration mail'); + throw new CRM_Core_Exception('Failed creating Activity for expiration mail'); } } } diff --git a/CRM/Event/BAO/ParticipantPayment.php b/CRM/Event/BAO/ParticipantPayment.php index 106b2bbae3..754e146e4a 100644 --- a/CRM/Event/BAO/ParticipantPayment.php +++ b/CRM/Event/BAO/ParticipantPayment.php @@ -104,7 +104,7 @@ class CRM_Event_BAO_ParticipantPayment extends CRM_Event_DAO_ParticipantPayment } if (!$valid) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Cannot delete participant payment'); } if ($participantPayment->find(TRUE)) { diff --git a/CRM/Event/Cart/BAO/Cart.php b/CRM/Event/Cart/BAO/Cart.php index 1acabfe0a3..1111171154 100644 --- a/CRM/Event/Cart/BAO/Cart.php +++ b/CRM/Event/Cart/BAO/Cart.php @@ -70,7 +70,7 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { if (is_a($cart, 'CRM_Core_Error')) { $transaction->rollback(); - CRM_Core_Error::fatal(ts('There was an error creating an event cart')); + throw new CRM_Core_Exception(ts('There was an error creating an event cart')); } $transaction->commit(); @@ -324,7 +324,7 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { public static function retrieve(&$params, &$values) { $cart = self::find_by_params($params); if ($cart === FALSE) { - CRM_Core_Error::fatal(ts('Could not find cart matching %1', [1 => var_export($params, TRUE)])); + throw new CRM_Core_Exception(ts('Could not find cart matching %1', [1 => var_export($params, TRUE)])); } CRM_Core_DAO::storeValues($cart, $values); return $values; diff --git a/CRM/Event/Cart/BAO/EventInCart.php b/CRM/Event/Cart/BAO/EventInCart.php index 7dd79ec725..abb9bb4ce6 100644 --- a/CRM/Event/Cart/BAO/EventInCart.php +++ b/CRM/Event/Cart/BAO/EventInCart.php @@ -40,7 +40,7 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl if (is_a($event_in_cart, 'CRM_Core_Error')) { $transaction->rollback(); - CRM_Core_Error::fatal(ts('There was an error creating an event_in_cart')); + throw new CRM_Core_Exception(ts('There was an error creating an event_in_cart')); } $transaction->commit(); diff --git a/CRM/Event/Form/ManageEvent/Repeat.php b/CRM/Event/Form/ManageEvent/Repeat.php index c7fb5591e1..3f1183d606 100644 --- a/CRM/Event/Form/ManageEvent/Repeat.php +++ b/CRM/Event/Form/ManageEvent/Repeat.php @@ -155,7 +155,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams)); } else { - CRM_Core_Error::fatal("Could not find Event ID"); + CRM_Core_Error::statusBounce("Could not find Event ID"); } parent::endPostProcess(); } diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 6b4c83d199..6c8b5cbbc2 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -113,7 +113,7 @@ WHERE e.id = %1 ]; $dao = CRM_Core_DAO::executeQuery($sql, $params); if (!$dao->fetch()) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to determine Event information');; } if (!$dao->is_location) { $tabs['location']['valid'] = FALSE; diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 638f2b8f2d..97ecf1f6f8 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -655,7 +655,7 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { } if ($isPaidEvent && empty($form->_values['fee'])) { if (CRM_Utils_System::getClassName($form) != 'CRM_Event_Form_Participant') { - CRM_Core_Error::fatal(ts('No Fee Level(s) or Price Set is configured for this event.
Click CiviEvent >> Manage Event >> Configure >> Event Fees to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId)))); + CRM_Core_Error::statusBounce(ts('No Fee Level(s) or Price Set is configured for this event.
Click CiviEvent >> Manage Event >> Configure >> Event Fees to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId)))); } } } diff --git a/CRM/Event/Import/Parser.php b/CRM/Event/Import/Parser.php index b168d2f9fe..c1ec6a7989 100644 --- a/CRM/Event/Import/Parser.php +++ b/CRM/Event/Import/Parser.php @@ -70,7 +70,7 @@ abstract class CRM_Event_Import_Parser extends CRM_Import_Parser { $onDuplicate = self::DUPLICATE_SKIP ) { if (!is_array($fileName)) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to determine import file'); } $fileName = $fileName['name']; diff --git a/CRM/Event/Page/ParticipantListing.php b/CRM/Event/Page/ParticipantListing.php index a9f718ca61..6c5ddf07c5 100644 --- a/CRM/Event/Page/ParticipantListing.php +++ b/CRM/Event/Page/ParticipantListing.php @@ -66,7 +66,7 @@ class CRM_Event_Page_ParticipantListing extends CRM_Core_Page { ) ); if ($className == 'CRM_Event_Page_ParticipantListing') { - CRM_Core_Error::fatal(ts("Participant listing code file cannot be '%1'", + CRM_Core_Error::statusBounce(ts("Participant listing code file cannot be '%1'", array(1 => $className) )); } @@ -77,7 +77,7 @@ class CRM_Event_Page_ParticipantListing extends CRM_Core_Page { ) . '.php'; $error = include_once $classFile; if ($error == FALSE) { - CRM_Core_Error::fatal('Participant listing code file: ' . $classFile . ' does not exist. Please verify your custom particpant listing settings in CiviCRM administrative panel.'); + CRM_Core_Error::statusBounce('Participant listing code file: ' . $classFile . ' does not exist. Please verify your custom particpant listing settings in CiviCRM administrative panel.'); } $participantListingClass = new $className(); diff --git a/CRM/Financial/Page/FinancialTypeAccount.php b/CRM/Financial/Page/FinancialTypeAccount.php index 9a3552cc61..cdbd3d5af9 100644 --- a/CRM/Financial/Page/FinancialTypeAccount.php +++ b/CRM/Financial/Page/FinancialTypeAccount.php @@ -166,8 +166,7 @@ class CRM_Financial_Page_FinancialTypeAccount extends CRM_Core_Page { $this->assign('financialTypeTitle', $this->_title); } else { - CRM_Core_Error::fatal(); - return NULL; + CRM_Core_Error::statusBounce('No Financial Accounts found for the Financial Type'); } } diff --git a/CRM/Member/Form/Task/Batch.php b/CRM/Member/Form/Task/Batch.php index 0d25822fee..5c9f976088 100644 --- a/CRM/Member/Form/Task/Batch.php +++ b/CRM/Member/Form/Task/Batch.php @@ -74,7 +74,7 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { $ufGroupId = $this->get('ufGroupId'); if (!$ufGroupId) { - CRM_Core_Error::fatal('ufGroupId is missing'); + CRM_Core_Error::statusBounce('ufGroupId is missing'); } $this->_title = ts('Update multiple memberships') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId); CRM_Utils_System::setTitle($this->_title); diff --git a/CRM/Member/Import/Parser.php b/CRM/Member/Import/Parser.php index e009c51365..7ad2f3f4cf 100644 --- a/CRM/Member/Import/Parser.php +++ b/CRM/Member/Import/Parser.php @@ -71,7 +71,7 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { $totalRowCount = NULL ) { if (!is_array($fileName)) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to determine import file'); } $fileName = $fileName['name']; diff --git a/CRM/Member/Page/DashBoard.php b/CRM/Member/Page/DashBoard.php index 8ba2539c13..62dcf8faeb 100644 --- a/CRM/Member/Page/DashBoard.php +++ b/CRM/Member/Page/DashBoard.php @@ -58,7 +58,7 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page { !checkdate(substr($ym, 4, 2), 1, substr($ym, 0, 4)) || substr($ym, 0, 1) == 0 ) { - CRM_Core_Error::fatal(ts('Invalid date query "%1" in URL (valid syntax is yyyymm).', array(1 => $ym))); + CRM_Core_Error::statusBounce(ts('Invalid date query "%1" in URL (valid syntax is yyyymm).', array(1 => $ym))); } $isPreviousMonth = 0; diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index a871f13b50..2ea752cded 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -665,7 +665,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id = %2 AND cc.is_test = 0"; if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') { $fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1'); - CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl])); + throw new CRM_Core_Exception(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl])); } $receiptFrom = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>'; @@ -913,7 +913,7 @@ INNER JOIN civicrm_uf_group ufgroup $params = [1 => [$component_id, 'Integer'], 2 => [$entity_table, 'String']]; if (!$supporterProfileId = CRM_Core_DAO::singleValueQuery($query, $params)) { - CRM_Core_Error::fatal(ts('Supporter profile is not set for this Personal Campaign Page or the profile is disabled. Please contact the site administrator if you need assistance.')); + throw new CRM_Core_Exception(ts('Supporter profile is not set for this Personal Campaign Page or the profile is disabled. Please contact the site administrator if you need assistance.')); } else { return $supporterProfileId; diff --git a/CRM/PCP/Form/Campaign.php b/CRM/PCP/Form/Campaign.php index 59c56d9ca9..bea78c69e2 100644 --- a/CRM/PCP/Form/Campaign.php +++ b/CRM/PCP/Form/Campaign.php @@ -300,7 +300,7 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') { $fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1'); - CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl])); + CRM_Core_Error::statusBounce(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl])); } //if more than one email present for PCP notification , diff --git a/CRM/PCP/Form/PCPAccount.php b/CRM/PCP/Form/PCPAccount.php index 502543f496..7c96a629cf 100644 --- a/CRM/PCP/Form/PCPAccount.php +++ b/CRM/PCP/Form/PCPAccount.php @@ -57,7 +57,7 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { if (!$this->_pageId) { if (!$this->_id) { $msg = ts('We can\'t load the requested web page due to an incomplete link. This can be caused by using your browser\'s Back button or by using an incomplete or invalid link.'); - CRM_Core_Error::fatal($msg); + CRM_Core_Error::statusBounce($msg); } else { $this->_pageId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $this->_id, 'page_id'); @@ -65,7 +65,7 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { } if (!$this->_pageId) { - CRM_Core_Error::fatal(ts('Could not find source page id.')); + CRM_Core_Error::statusBounce(ts('Could not find source page id.')); } $this->_single = $this->get('single'); diff --git a/CRM/Price/Form/Option.php b/CRM/Price/Form/Option.php index ff7a875881..750bfb7f99 100644 --- a/CRM/Price/Form/Option.php +++ b/CRM/Price/Form/Option.php @@ -109,7 +109,7 @@ class CRM_Price_Form_Option extends CRM_Core_Form { if ($this->_action == CRM_Core_Action::UPDATE) { $finTypeId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_oid, 'financial_type_id'); if (!CRM_Financial_BAO_FinancialType::checkPermissionToEditFinancialType($finTypeId)) { - CRM_Core_Error::fatal(ts("You do not have permission to access this page")); + CRM_Core_Error::statusBounce(ts("You do not have permission to access this page")); } } if ($this->_action == CRM_Core_Action::DELETE) { diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index 1d03a0a683..31fe2d96bd 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -306,7 +306,7 @@ class CRM_Profile_Form extends CRM_Core_Form { if ($this->_multiRecord && !in_array($this->_multiRecord, [CRM_Core_Action::UPDATE, CRM_Core_Action::ADD, CRM_Core_Action::DELETE]) ) { - CRM_Core_Error::fatal(ts('Proper action not specified for this custom value record profile')); + CRM_Core_Error::statusBounce(ts('Proper action not specified for this custom value record profile')); } } $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate'); @@ -322,7 +322,7 @@ class CRM_Profile_Form extends CRM_Core_Form { // check if we are rendering mixed profiles if (CRM_Core_BAO_UFGroup::checkForMixProfiles($this->_profileIds)) { - CRM_Core_Error::fatal(ts('You cannot combine profiles of multiple types.')); + CRM_Core_Error::statusBounce(ts('You cannot combine profiles of multiple types.')); } // for now consider 1'st profile as primary profile and validate it @@ -358,7 +358,7 @@ class CRM_Profile_Form extends CRM_Core_Form { } if (empty($this->_ufGroup['is_active'])) { - CRM_Core_Error::fatal(ts('The requested profile (gid=%1) is inactive or does not exist.', [ + CRM_Core_Error::statusBounce(ts('The requested profile (gid=%1) is inactive or does not exist.', [ 1 => $this->_gid, ])); } @@ -407,12 +407,12 @@ class CRM_Profile_Form extends CRM_Core_Form { if (!$this->_recordId && ($this->_multiRecord == CRM_Core_Action::UPDATE || $this->_multiRecord == CRM_Core_Action::DELETE) ) { - CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) requires record id while performing this action', + CRM_Core_Error::statusBounce(ts('The requested Profile (gid=%1) requires record id while performing this action', [1 => $this->_gid] )); } elseif (empty($this->_multiRecordFields)) { - CRM_Core_Error::fatal(ts('No Multi-Record Fields configured for this profile (gid=%1)', + CRM_Core_Error::statusBounce(ts('No Multi-Record Fields configured for this profile (gid=%1)', [1 => $this->_gid] )); } diff --git a/CRM/Profile/Page/Dynamic.php b/CRM/Profile/Page/Dynamic.php index 0ef7350a78..67f7edf0d5 100644 --- a/CRM/Profile/Page/Dynamic.php +++ b/CRM/Profile/Page/Dynamic.php @@ -237,7 +237,7 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { if ($this->_isContactActivityProfile && $this->_gid) { $errors = CRM_Profile_Form::validateContactActivityProfile($this->_activityId, $this->_id, $this->_gid); if (!empty($errors)) { - CRM_Core_Error::fatal(array_pop($errors)); + CRM_Core_Error::statusBounce(array_pop($errors)); } } diff --git a/CRM/Profile/Page/Listings.php b/CRM/Profile/Page/Listings.php index 46807507ce..963d59b27f 100644 --- a/CRM/Profile/Page/Listings.php +++ b/CRM/Profile/Page/Listings.php @@ -100,7 +100,7 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { // check if we are rendering mixed profiles if (CRM_Core_BAO_UFGroup::checkForMixProfiles($this->_profileIds)) { - CRM_Core_Error::fatal(ts('You cannot combine profiles of multiple types.')); + CRM_Core_Error::statusBounce(ts('You cannot combine profiles of multiple types.')); } $this->_gid = $this->_profileIds[0]; @@ -282,7 +282,7 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { $ufgroupDAO = new CRM_Core_DAO_UFGroup(); $ufgroupDAO->id = $this->_gid; if (!$ufgroupDAO->find(TRUE)) { - CRM_Core_Error::fatal(); + CRM_Core_Error::statusBounce('Unable to find matching UF Group'); } } diff --git a/CRM/Profile/Page/View.php b/CRM/Profile/Page/View.php index 0dbaf37bf0..e23fada8bd 100644 --- a/CRM/Profile/Page/View.php +++ b/CRM/Profile/Page/View.php @@ -49,7 +49,7 @@ class CRM_Profile_Page_View extends CRM_Core_Page { $session = CRM_Core_Session::singleton(); $this->_id = $session->get('userID'); if (!$this->_id) { - CRM_Core_Error::fatal(ts('Could not find the required contact id parameter (id=) for viewing a contact record with a Profile.')); + CRM_Core_Error::statusBounce(ts('Could not find the required contact id parameter (id=) for viewing a contact record with a Profile.')); } } $this->assign('cid', $this->_id); @@ -66,7 +66,7 @@ class CRM_Profile_Page_View extends CRM_Core_Page { // check if we are rendering mixed profiles if (CRM_Core_BAO_UFGroup::checkForMixProfiles($profileIds)) { - CRM_Core_Error::fatal(ts('You cannot combine profiles of multiple types.')); + CRM_Core_Error::statusBounce(ts('You cannot combine profiles of multiple types.')); } $this->_gid = $profileIds[0]; diff --git a/CRM/Queue/Page/Runner.php b/CRM/Queue/Page/Runner.php index 07ca85b1d0..ac46d87104 100644 --- a/CRM/Queue/Page/Runner.php +++ b/CRM/Queue/Page/Runner.php @@ -36,7 +36,7 @@ class CRM_Queue_Page_Runner extends CRM_Core_Page { $qrid = CRM_Utils_Request::retrieve('qrid', 'String', $this, TRUE); $runner = CRM_Queue_Runner::instance($qrid); if (!is_object($runner)) { - CRM_Core_Error::fatal('Queue runner must be configured before execution.'); + CRM_Core_Error::statusBounce('Queue runner must be configured before execution.'); } CRM_Utils_System::setTitle($runner->title); diff --git a/CRM/Queue/Queue/Sql.php b/CRM/Queue/Queue/Sql.php index 1258b533a8..3f6c474a94 100644 --- a/CRM/Queue/Queue/Sql.php +++ b/CRM/Queue/Queue/Sql.php @@ -130,7 +130,7 @@ class CRM_Queue_Queue_Sql extends CRM_Queue_Queue { $dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, 'CRM_Queue_DAO_QueueItem'); if (is_a($dao, 'DB_Error')) { // FIXME - Adding code to allow tests to pass - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to claim queue item'); } if ($dao->fetch()) { diff --git a/CRM/UF/Page/ProfileEditor.php b/CRM/UF/Page/ProfileEditor.php index 0d2b09e9b0..466278a3fa 100644 --- a/CRM/UF/Page/ProfileEditor.php +++ b/CRM/UF/Page/ProfileEditor.php @@ -14,7 +14,7 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page { * @throws \Exception */ public function run() { - CRM_Core_Error::fatal('This is not a real page!'); + throw new CRM_Core_Exception('This is not a real page!'); } /** -- 2.25.1