From ac15829d848fb7ba6b8068cf5cab81a2f8f6b518 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 18 May 2020 09:48:55 +1000 Subject: [PATCH] dev/core#560 Replace depreacted CRM_Core_Error::fatal with either statusBounce or Exceptions as appropriate in CRM/Core folder update langauge as per demeritcowboy --- CRM/Case/XMLProcessor/Process.php | 8 ++++---- CRM/Core/BAO/ActionSchedule.php | 3 ++- CRM/Core/BAO/Address.php | 2 +- CRM/Core/BAO/Block.php | 3 ++- CRM/Core/BAO/Cache.php | 3 ++- CRM/Core/BAO/CustomField.php | 11 +++++++---- CRM/Core/BAO/CustomOption.php | 2 +- CRM/Core/BAO/CustomValueTable.php | 7 ++++--- CRM/Core/BAO/Discount.php | 3 ++- CRM/Core/BAO/File.php | 4 ++-- CRM/Core/BAO/Job.php | 3 ++- CRM/Core/BAO/LabelFormat.php | 2 +- CRM/Core/BAO/Location.php | 3 ++- CRM/Core/BAO/Mapping.php | 3 ++- CRM/Core/BAO/PaperSize.php | 10 ++++++---- CRM/Core/BAO/PdfFormat.php | 10 ++++++---- CRM/Core/BAO/PreferencesDate.php | 6 ++++-- CRM/Core/BAO/RecurringEntity.php | 10 ++++++---- CRM/Core/BAO/SchemaHandler.php | 4 ++-- CRM/Core/BAO/StatusPreference.php | 5 +++-- CRM/Core/BAO/UFGroup.php | 2 +- CRM/Core/BAO/UFMatch.php | 4 +++- CRM/Core/BAO/WordReplacement.php | 3 ++- CRM/Core/Form.php | 4 ++-- CRM/Core/I18n/Form.php | 4 ++-- CRM/Core/Menu.php | 12 +++++++----- 26 files changed, 78 insertions(+), 53 deletions(-) diff --git a/CRM/Case/XMLProcessor/Process.php b/CRM/Case/XMLProcessor/Process.php index 2385eaf200..9307f2bb90 100644 --- a/CRM/Case/XMLProcessor/Process.php +++ b/CRM/Case/XMLProcessor/Process.php @@ -186,7 +186,7 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { * @param array $params * * @return bool - * @throws Exception + * @throws CRM_Core_Exception */ public function createRelationships($relationshipTypeXML, &$params) { @@ -723,16 +723,16 @@ AND a.is_deleted = 0 /** * @param $caseType - * @param null $activityTypeName + * @param string|null $activityTypeName * * @return array|bool|mixed - * @throws Exception + * @throws CRM_Core_Exception */ public function getMaxInstance($caseType, $activityTypeName = NULL) { $xml = $this->retrieve($caseType); if ($xml === FALSE) { - throw new CRM_Core_Exception('Unable to read supplied XML File'); + throw new CRM_Core_Exception('Unable to locate xml definition for case type ' . $caseType); } $activityInstances = $this->activityTypes($xml->ActivityTypes, TRUE); diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index c1d7ec1a10..a53e0e6232 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -226,6 +226,7 @@ FROM civicrm_action_schedule cas * @param int $id * ID of the Reminder to be deleted. * + * @throws CRM_Core_Exception */ public static function del($id) { if ($id) { @@ -236,7 +237,7 @@ FROM civicrm_action_schedule cas return; } } - CRM_Core_Error::fatal(ts('Invalid value passed to delete function.')); + throw new CRM_Core_Exception(ts('Invalid value passed to delete function.')); } /** diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index e22a25cecd..c0f6561c8a 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -1181,7 +1181,7 @@ SELECT is_primary, $relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Household Member of', 'id', 'name_a_b'); if (!$relTypeId) { - CRM_Core_Error::fatal(ts("You seem to have deleted the relationship type 'Household Member of'")); + throw new CRM_Core_Exception(ts("You seem to have deleted the relationship type 'Household Member of'")); } $relParam = [ diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index a36b698e66..876cd323c5 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -40,6 +40,7 @@ class CRM_Core_BAO_Block { * * @return array * Array of $block objects. + * @throws CRM_Core_Exception */ public static function &getValues($blockName, $params) { if (empty($params)) { @@ -52,7 +53,7 @@ class CRM_Core_BAO_Block { if (!isset($params['entity_table'])) { $block->contact_id = $params['contact_id']; if (!$block->contact_id) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Invalid Contact ID parameter passed'); } $blocks = self::retrieveBlock($block, $blockName); } diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index ee678348dd..a13a6fee85 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -149,6 +149,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { * @param int $componentID * The optional component ID (so componenets can share the same name space). * @deprecated + * @throws CRM_Core_Exception */ public static function setItem(&$data, $group, $path, $componentID = NULL) { CRM_Core_Error::deprecatedFunctionWarning( @@ -167,7 +168,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { // CRM-11234 $lock = Civi::lockManager()->acquire("cache.{$group}_{$path}._{$componentID}"); if (!$lock->isAcquired()) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Cannot acquire database lock'); } $table = self::getTableName(); diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index e66aaf6f0b..a682676e74 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -608,6 +608,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { * * @return CRM_Core_BAO_CustomField * The field object. + * @throws CRM_Core_Exception */ public static function getFieldObject($fieldID) { $field = new CRM_Core_BAO_CustomField(); @@ -619,7 +620,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { if (empty($fieldValues)) { $field->id = $fieldID; if (!$field->find(TRUE)) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Cannot find Custom Field'); } $fieldValues = []; @@ -1777,11 +1778,13 @@ WHERE id IN ( %1, %2 ) * FK to civicrm_custom_field. * @param int $newGroupID * FK to civicrm_custom_group. + * + * @throws CRM_Core_Exception */ public static function moveField($fieldID, $newGroupID) { $validation = self::_moveFieldValidate($fieldID, $newGroupID); if (TRUE !== $validation) { - CRM_Core_Error::fatal(implode(' ', $validation)); + throw new CRM_Core_Exception(implode(' ', $validation)); } $field = new CRM_Core_DAO_CustomField(); $field->id = $fieldID; @@ -2070,7 +2073,7 @@ WHERE id IN ( %1, %2 ) * * @return array * fatal is fieldID does not exists, else array of tableName, columnName - * @throws \Exception + * @throws \CRM_Core_Exception */ public static function getTableColumnGroup($fieldID, $force = FALSE) { $cacheKey = "CRM_Core_DAO_CustomField_CustomGroup_TableColumn_{$fieldID}"; @@ -2087,7 +2090,7 @@ AND cf.id = %1"; $dao = CRM_Core_DAO::executeQuery($query, $params); if (!$dao->fetch()) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception("Cannot find table and column information for Custom Field " . $fieldID); } $fieldValues = [$dao->table_name, $dao->column_name, $dao->id]; $cache->set($cacheKey, $fieldValues); diff --git a/CRM/Core/BAO/CustomOption.php b/CRM/Core/BAO/CustomOption.php index 9009cce0ac..e876436f75 100644 --- a/CRM/Core/BAO/CustomOption.php +++ b/CRM/Core/BAO/CustomOption.php @@ -277,7 +277,7 @@ SET {$dao->columnName} = REPLACE( {$dao->columnName}, %1, %2 )"; break; default: - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Invalid HTML Type'); } $dao = CRM_Core_DAO::executeQuery($query, $queryParams); } diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index 1fa9a508a8..0a724557b8 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -153,7 +153,7 @@ class CRM_Core_BAO_CustomValueTable { case 'File': if (!$field['file_id']) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Missing parameter file_id'); } // need to add/update civicrm_entity_file @@ -318,7 +318,7 @@ class CRM_Core_BAO_CustomValueTable { return 'datetime'; default: - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Invalid Field Type'); } } @@ -415,12 +415,13 @@ class CRM_Core_BAO_CustomValueTable { * Array of custom values for the entity with key=>value * pairs specified as civicrm_custom_field.id => custom value. * Empty array if no custom values found. + * @throws CRM_Core_Exception */ public static function &getEntityValues($entityID, $entityType = NULL, $fieldIDs = NULL, $formatMultiRecordField = FALSE, $DTparams = NULL) { if (!$entityID) { // adding this here since an empty contact id could have serious repurcussions // like looping forever - CRM_Core_Error::fatal('Please file an issue with the backtrace'); + throw new CRM_Core_Exception('Please file an issue with the backtrace'); return NULL; } diff --git a/CRM/Core/BAO/Discount.php b/CRM/Core/BAO/Discount.php index ce24c32e4e..812747eb42 100644 --- a/CRM/Core/BAO/Discount.php +++ b/CRM/Core/BAO/Discount.php @@ -98,11 +98,12 @@ class CRM_Core_BAO_Discount extends CRM_Core_DAO_Discount { * @return int * $dao->id discount id of the set which matches * the date criteria + * @throws CRM_Core_Exception */ public static function findSet($entityID, $entityTable) { if (empty($entityID) || empty($entityTable)) { // adding this here, to trap errors if values are not sent - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Invalid parameters passed to findSet function'); return NULL; } diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index 3e78e3ffea..e8c2ad6052 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -677,7 +677,7 @@ AND CEF.entity_id = %2"; /** * Delete a file attachment from an entity table / entity ID - * + * @throws CRM_Core_Exception */ public static function deleteAttachment() { $params = []; @@ -689,7 +689,7 @@ AND CEF.entity_id = %2"; $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), self::$_signableFields); if (!$signer->validate($signature, $params)) { - CRM_Core_Error::fatal('Request signature is invalid'); + throw new CRM_Core_Exception('Request signature is invalid'); } self::deleteEntityFile($params['entityTable'], $params['entityID'], NULL, $params['fileID']); diff --git a/CRM/Core/BAO/Job.php b/CRM/Core/BAO/Job.php index 5609b3075f..5cbcd121fd 100644 --- a/CRM/Core/BAO/Job.php +++ b/CRM/Core/BAO/Job.php @@ -88,10 +88,11 @@ class CRM_Core_BAO_Job extends CRM_Core_DAO_Job { * ID of the job to be deleted. * * @return bool|null + * @throws CRM_Core_Exception */ public static function del($jobID) { if (!$jobID) { - 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_Core_DAO_Job(); diff --git a/CRM/Core/BAO/LabelFormat.php b/CRM/Core/BAO/LabelFormat.php index 175d599410..8678560c9c 100644 --- a/CRM/Core/BAO/LabelFormat.php +++ b/CRM/Core/BAO/LabelFormat.php @@ -527,7 +527,7 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { // make sure serialized array will fit in the 'value' column $attribute = CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat', 'value'); if (strlen($this->value) > $attribute['maxlength']) { - CRM_Core_Error::fatal(ts('Label Format does not fit in database.')); + throw new CRM_Core_Exception(ts('Label Format does not fit in database.')); } $this->save(); diff --git a/CRM/Core/BAO/Location.php b/CRM/Core/BAO/Location.php index ec50cd15f0..e2d393976c 100644 --- a/CRM/Core/BAO/Location.php +++ b/CRM/Core/BAO/Location.php @@ -260,13 +260,14 @@ WHERE e.id = %1"; * Contact id. * @param int $locationTypeId * Id of the location to delete. + * @throws CRM_Core_Exception */ public static function deleteLocationBlocks($contactId, $locationTypeId) { // ensure that contactId has a value if (empty($contactId) || !CRM_Utils_Rule::positiveInteger($contactId) ) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Incorrect contact id parameter passed to deleteLocationBlocks'); } if (empty($locationTypeId) || diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index 19c6ec2290..56c1d9e020 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -1002,6 +1002,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * * @return array * formatted associated array of elements + * @throws CRM_Core_Exception */ public static function formattedFields(&$params, $row = FALSE) { $fields = []; @@ -1016,7 +1017,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { foreach ($value as $k => $v) { if (in_array($v[0], $types)) { if ($contactType && $contactType != $v[0]) { - CRM_Core_Error::fatal(ts("Cannot have two clauses with different types: %1, %2", + throw new CRM_Core_Exception(ts("Cannot have two clauses with different types: %1, %2", [1 => $contactType, 2 => $v[0]] )); } diff --git a/CRM/Core/BAO/PaperSize.php b/CRM/Core/BAO/PaperSize.php index c14709e855..f7456bc50d 100644 --- a/CRM/Core/BAO/PaperSize.php +++ b/CRM/Core/BAO/PaperSize.php @@ -72,12 +72,13 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { * * @return int * Group ID (null if Group ID doesn't exist) + * @throws CRM_Core_Exception */ private static function _getGid() { if (!self::$_gid) { self::$_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'paper_size', 'id', 'name'); if (!self::$_gid) { - CRM_Core_Error::fatal(ts('Paper Size Option Group not found in database.')); + throw new CRM_Core_Exception(ts('Paper Size Option Group not found in database.')); } } return self::$_gid; @@ -268,6 +269,7 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { * @param array $values associative array of name/value pairs * @param int $id * Id of the database record (null = new record). + * @throws CRM_Core_Exception */ public function savePaperSize(&$values, $id) { // get the Option Group ID for Paper Sizes (create one if it doesn't exist) @@ -311,7 +313,7 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { // make sure serialized array will fit in the 'value' column $attribute = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PaperSize', 'value'); if (strlen($this->value) > $attribute['maxlength']) { - CRM_Core_Error::fatal(ts('Paper Size does not fit in database.')); + throw new CRM_Core_Exception(ts('Paper Size does not fit in database.')); } $this->save(); @@ -325,7 +327,7 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { * * @param int $id * ID of the Paper Size to be deleted. - * + * @throws CRM_Core_Exception */ public static function del($id) { if ($id) { @@ -340,7 +342,7 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { } } } - CRM_Core_Error::fatal(ts('Invalid value passed to delete function.')); + throw new CRM_Core_Exception(ts('Invalid value passed to delete function.')); } } diff --git a/CRM/Core/BAO/PdfFormat.php b/CRM/Core/BAO/PdfFormat.php index 0703108a7f..33783d7306 100644 --- a/CRM/Core/BAO/PdfFormat.php +++ b/CRM/Core/BAO/PdfFormat.php @@ -127,12 +127,13 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { * * @return int * Group ID (null if Group ID doesn't exist) + * @throws CRM_Core_Exception */ private static function _getGid() { if (!self::$_gid) { self::$_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'pdf_format', 'id', 'name'); if (!self::$_gid) { - CRM_Core_Error::fatal(ts('PDF Format Option Group not found in database.')); + throw new CRM_Core_Exception(ts('PDF Format Option Group not found in database.')); } } return self::$_gid; @@ -325,6 +326,7 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { * @param array $values associative array of name/value pairs * @param int $id * Id of the database record (null = new record). + * @throws CRM_Core_Exception */ public function savePdfFormat(&$values, $id = NULL) { // get the Option Group ID for PDF Page Formats (create one if it doesn't exist) @@ -364,7 +366,7 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { // make sure serialized array will fit in the 'value' column $attribute = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'value'); if (strlen($this->value) > $attribute['maxlength']) { - CRM_Core_Error::fatal(ts('PDF Page Format does not fit in database.')); + throw new CRM_Core_Exception(ts('PDF Page Format does not fit in database.')); } $this->save(); @@ -378,7 +380,7 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { * * @param int $id * ID of the PDF Page Format to be deleted. - * + * @throws CRM_Core_Exception */ public static function del($id) { if ($id) { @@ -393,7 +395,7 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { } } } - CRM_Core_Error::fatal(ts('Invalid value passed to delete function.')); + throw new CRM_Core_Exception(ts('Invalid value passed to delete function.')); } } diff --git a/CRM/Core/BAO/PreferencesDate.php b/CRM/Core/BAO/PreferencesDate.php index 513bba5dd5..b05bbf4a15 100644 --- a/CRM/Core/BAO/PreferencesDate.php +++ b/CRM/Core/BAO/PreferencesDate.php @@ -57,18 +57,20 @@ class CRM_Core_BAO_PreferencesDate extends CRM_Core_DAO_PreferencesDate { * Id of the database record. * @param bool $is_active * Value we want to set the is_active field. + * @throws CRM_Core_Exception */ public static function setIsActive($id, $is_active) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Cannot call setIsActive function'); } /** * Delete preference dates. * * @param int $id + * @throws CRM_Core_Exception */ public static function del($id) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Cannot call del function'); } /** diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index f4b1622de9..fceb1237b1 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -224,6 +224,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * Generate new DAOs and along with entries in civicrm_recurring_entity table. * * @return array + * @throws CRM_Core_Exception */ public function generateEntities() { self::setStatus(self::RUNNING); @@ -241,7 +242,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } } if (empty($findCriteria)) { - CRM_Core_Error::fatal("Find criteria missing to generate form. Make sure entity_id and table is set."); + throw new CRM_Core_Exception("Find criteria missing to generate form. Make sure entity_id and table is set."); } $count = 0; @@ -547,11 +548,12 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * * * @return object + * @throws new CRM_Core_Exception */ public static function copyCreateEntity($entityTable, $fromCriteria, $newParams, $createRecurringEntity = TRUE) { $daoName = self::$_tableDAOMapper[$entityTable]; if (!$daoName) { - CRM_Core_Error::fatal("DAO Mapper missing for $entityTable."); + throw new CRM_Core_Exception("DAO Mapper missing for $entityTable."); } $newObject = CRM_Core_DAO::copyGeneric($daoName, $fromCriteria, $newParams); @@ -631,7 +633,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $updateDAO = CRM_Core_DAO::cascadeUpdate($daoName, $obj->id, $entityID, $skipData); } else { - CRM_Core_Error::fatal("DAO Mapper missing for $entityTable."); + throw new CRM_Core_Exception("DAO Mapper missing for $entityTable."); } } // done with processing. lets unset static var. @@ -811,7 +813,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { foreach (self::$_linkedEntitiesInfo as $linkedTable => $linfo) { $daoName = self::$_tableDAOMapper[$linkedTable]; if (!$daoName) { - CRM_Core_Error::fatal("DAO Mapper missing for $linkedTable."); + throw new CRM_Core_Exception("DAO Mapper missing for $linkedTable."); } $linkedDao = new $daoName(); diff --git a/CRM/Core/BAO/SchemaHandler.php b/CRM/Core/BAO/SchemaHandler.php index c6757015f0..48a820916a 100644 --- a/CRM/Core/BAO/SchemaHandler.php +++ b/CRM/Core/BAO/SchemaHandler.php @@ -502,7 +502,7 @@ ADD UNIQUE INDEX `unique_entity_id` ( `entity_id` )"; * @param string $columnName * @param $length * - * @throws Exception + * @throws CRM_Core_Exception */ public static function alterFieldLength($customFieldID, $tableName, $columnName, $length) { // first update the custom field tables @@ -543,7 +543,7 @@ MODIFY {$columnName} varchar( $length ) CRM_Core_DAO::executeQuery($sql); } else { - CRM_Core_Error::fatal(ts('Could Not Find Custom Field Details for %1, %2, %3', + throw new CRM_Core_Exception(ts('Could Not Find Custom Field Details for %1, %2, %3', [ 1 => $tableName, 2 => $columnName, diff --git a/CRM/Core/BAO/StatusPreference.php b/CRM/Core/BAO/StatusPreference.php index 2f225ee9fe..d4e182eadc 100644 --- a/CRM/Core/BAO/StatusPreference.php +++ b/CRM/Core/BAO/StatusPreference.php @@ -28,6 +28,7 @@ class CRM_Core_BAO_StatusPreference extends CRM_Core_DAO_StatusPreference { * @param array $params * * @return array + * @throws CRM_Core_Exception */ public static function create($params) { $statusPreference = new CRM_Core_BAO_StatusPreference(); @@ -42,11 +43,11 @@ class CRM_Core_BAO_StatusPreference extends CRM_Core_DAO_StatusPreference { $params['ignore_severity'] = CRM_Utils_Check::severityMap($params['ignore_severity']); } if ($params['ignore_severity'] > 7) { - CRM_Core_Error::fatal(ts('You can not pass a severity level higher than 7.')); + throw new CRM_Core_Exception(ts('You can not pass a severity level higher than 7.')); } // If severity is now blank, you have an invalid severity string. if (is_null($params['ignore_severity'])) { - CRM_Core_Error::fatal(ts('Invalid string passed as severity level.')); + throw new CRM_Core_Exception(ts('Invalid string passed as severity level.')); } // Check if this StatusPreference already exists. diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index d23e665637..5841ab0d72 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -2700,7 +2700,7 @@ AND ( entity_id IS NULL OR entity_id <= 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])); + 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])); } foreach ($emailList as $emailTo) { diff --git a/CRM/Core/BAO/UFMatch.php b/CRM/Core/BAO/UFMatch.php index 116ebd141c..b7dd9b2c80 100644 --- a/CRM/Core/BAO/UFMatch.php +++ b/CRM/Core/BAO/UFMatch.php @@ -57,12 +57,14 @@ class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch { * * @param $ctype * @param bool $isLogin + * + * @throws CRM_Core_Exception */ public static function synchronize(&$user, $update, $uf, $ctype, $isLogin = FALSE) { $userSystem = CRM_Core_Config::singleton()->userSystem; $session = CRM_Core_Session::singleton(); if (!is_object($session)) { - CRM_Core_Error::fatal('wow, session is not an object?'); + throw new CRM_Core_Exception('wow, session is not an object?'); return; } diff --git a/CRM/Core/BAO/WordReplacement.php b/CRM/Core/BAO/WordReplacement.php index d8fe9df6b3..ba4f09d7fa 100644 --- a/CRM/Core/BAO/WordReplacement.php +++ b/CRM/Core/BAO/WordReplacement.php @@ -51,6 +51,7 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { * @param null $reset * * @return null|CRM_Core_BAO_WordReplacement + * @throws CRM_Core_Exception */ public static function getWordReplacement($reset = NULL) { static $wordReplacement = NULL; @@ -58,7 +59,7 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { $wordReplacement = new CRM_Core_BAO_WordReplacement(); $wordReplacement->id = CRM_Core_Config::wordReplacementID(); if (!$wordReplacement->find(TRUE)) { - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to find word replacement'); } } return $wordReplacement; diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 416085c733..060f4e6881 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -421,7 +421,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $element = $this->addElement($type, $name, CRM_Utils_String::purifyHTML($label), $attributes, $extra); if (HTML_QuickForm::isError($element)) { - CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element)); + CRM_Core_Error::statusBounce(HTML_QuickForm::errorMessage($element)); } if ($inputType == 'color') { @@ -436,7 +436,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $error = $this->addRule($name, ts('%1 is a required field.', [1 => $label]), 'required'); } if (HTML_QuickForm::isError($error)) { - CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element)); + CRM_Core_Error::statusBounce(HTML_QuickForm::errorMessage($element)); } } diff --git a/CRM/Core/I18n/Form.php b/CRM/Core/I18n/Form.php index 2c36e24639..6beb1d669d 100644 --- a/CRM/Core/I18n/Form.php +++ b/CRM/Core/I18n/Form.php @@ -27,7 +27,7 @@ class CRM_Core_I18n_Form extends CRM_Core_Form { $id = CRM_Utils_Request::retrieve('id', 'Int', $this); $this->_structure = CRM_Core_I18n_SchemaStructure::columns(); if (!isset($this->_structure[$table][$field])) { - CRM_Core_Error::fatal("$table.$field is not internationalized."); + CRM_Core_Error::statusBounce("$table.$field is not internationalized."); } $this->addElement('hidden', 'table', $table); @@ -106,7 +106,7 @@ class CRM_Core_I18n_Form extends CRM_Core_Form { // validate table and field if (!isset($this->_structure[$table][$field])) { - CRM_Core_Error::fatal("$table.$field is not internationalized."); + CRM_Core_Error::statusBounce("$table.$field is not internationalized."); } $cols = []; diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php index 79e4f552f3..bd9900df2f 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -105,13 +105,15 @@ class CRM_Core_Menu { * An XML document defining a list of menu items. * @param array $menu * An alterable list of menu items. + * + * @throws CRM_Core_Exception */ public static function readXML($xml, &$menu) { $config = CRM_Core_Config::singleton(); foreach ($xml->item as $item) { if (!(string ) $item->path) { CRM_Core_Error::debug('i', $item); - CRM_Core_Error::fatal(); + throw new CRM_Core_Exception('Unable to read XML file'); } $path = (string ) $item->path; $menu[$path] = array(); @@ -204,7 +206,7 @@ class CRM_Core_Menu { * @param array $menu * @param string $path * - * @throws Exception + * @throws CRM_Core_Exception */ public static function fillMenuValues(&$menu, $path) { $fieldsToPropagate = array( @@ -240,15 +242,15 @@ class CRM_Core_Menu { return; } - $messages = array(); + $messages = []; foreach ($fieldsToPropagate as $field) { if (!$fieldsPresent[$field]) { $messages[] = ts("Could not find %1 in path tree", - array(1 => $field) + [1 => $field] ); } } - CRM_Core_Error::fatal("'$path': " . implode(', ', $messages)); + throw new CRM_Core_Exception("'$path': " . implode(', ', $messages)); } /** -- 2.25.1