Skip to content

Commit

Permalink
Merge pull request #16141 from eileenmcnaughton/fatal
Browse files Browse the repository at this point in the history
dev/core#560 Remove instances of fatal errors
  • Loading branch information
eileenmcnaughton authored Dec 22, 2019
2 parents e030dda + 0d32dc8 commit a619b65
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions CRM/Contact/BAO/Contact/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CRM_Contact_BAO_Contact_Utils {
* If profile overlay class should be added.
*
* @return string
* @throws \CRM_Core_Exception
*/
public static function getImage($contactType, $urlOnly = FALSE, $contactId = NULL, $addProfileOverlay = TRUE) {
static $imageInfo = [];
Expand Down Expand Up @@ -136,6 +137,7 @@ public static function checkContactType(&$contactIds) {
*
* @return array
* ( $cs, $ts, $live )
* @throws \CRM_Core_Exception
*/
public static function generateChecksum($entityId, $ts = NULL, $live = NULL, $hash = NULL, $entityType = 'contact', $hashSize = NULL) {
// return a warning message if we dont get a entityId
Expand Down Expand Up @@ -200,6 +202,8 @@ public static function generateChecksum($entityId, $ts = NULL, $live = NULL, $ha
*
* @return bool
* true if valid, else false
*
* @throws \CRM_Core_Exception
*/
public static function validChecksum($contactID, $inputCheck) {

Expand Down Expand Up @@ -236,6 +240,8 @@ public static function validChecksum($contactID, $inputCheck) {
* @param int $previousEmployerID
* @param bool $newContact
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function createCurrentEmployerRelationship($contactID, $organization, $previousEmployerID = NULL, $newContact = FALSE) {
//if organization name is passed. CRM-15368,CRM-15547
Expand Down Expand Up @@ -266,7 +272,7 @@ public static function createCurrentEmployerRelationship($contactID, $organizati
// get the relationship type id of "Employee of"
$relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
if (!$relTypeId) {
CRM_Core_Error::fatal(ts("You seem to have deleted the relationship type 'Employee of'"));
throw new CRM_Core_Exception(ts("You seem to have deleted the relationship type 'Employee of'"));
}

// create employee of relationship
Expand Down Expand Up @@ -312,6 +318,7 @@ public static function createCurrentEmployerRelationship($contactID, $organizati
* @param int $previousEmpID
*
* @throws CiviCRM_API3_Exception
* @throws \CRM_Core_Exception
*/
public static function currentEmployerRelatedMembership($contactID, $employerID, $relationshipParams, $duplicate = FALSE, $previousEmpID = NULL) {
$ids = [];
Expand Down Expand Up @@ -374,6 +381,9 @@ public static function updateCurrentEmployer($organizationId) {
* Contact id ( mostly individual contact id).
* @param int $employerId
* Contact id ( mostly organization contact id).
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function clearCurrentEmployer($contactId, $employerId = NULL) {
$query = "UPDATE civicrm_contact
Expand All @@ -390,7 +400,7 @@ public static function clearCurrentEmployer($contactId, $employerId = NULL) {
//get the relationship type id of "Employee of"
$relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
if (!$relTypeId) {
CRM_Core_Error::fatal(ts("You seem to have deleted the relationship type 'Employee of'"));
throw new CRM_Core_Exception(ts("You seem to have deleted the relationship type 'Employee of'"));
}
$relMembershipParams['relationship_type_id'] = $relTypeId . '_a_b';
$relMembershipParams['contact_check'][$employerId] = 1;
Expand Down Expand Up @@ -424,6 +434,7 @@ public static function clearCurrentEmployer($contactId, $employerId = NULL) {
* @param string $title
* fieldset title.
*
* @throws \CiviCRM_API3_Exception
*/
public static function buildOnBehalfForm(&$form, $contactType, $countryID, $stateID, $title) {
$form->assign('contact_type', $contactType);
Expand Down Expand Up @@ -902,7 +913,7 @@ public static function updateGreeting($params) {
$allGreetings = CRM_Core_PseudoConstant::greeting($filter);
$originalGreetingString = $greetingString = CRM_Utils_Array::value($valueID, $allGreetings);
if (!$greetingString) {
CRM_Core_Error::fatal(ts('Incorrect greeting value id %1, or no default greeting for this contact type and greeting type.', [1 => $valueID]));
throw new CRM_Core_Exception(ts('Incorrect greeting value id %1, or no default greeting for this contact type and greeting type.', [1 => $valueID]));
}

// build return properties based on tokens
Expand Down Expand Up @@ -1119,7 +1130,9 @@ public static function processGreetingTemplate(&$templateString, $contactDetails
*
* @param int $contactId
* The hypothetical contact ID
*
* @return bool
* @throws \CRM_Core_Exception
*/
public static function isContactId($contactId) {
if ($contactId) {
Expand Down

0 comments on commit a619b65

Please sign in to comment.