From fba045e1d152968400b6916099ae01319a289591 Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 13 Sep 2020 19:54:30 +1200 Subject: [PATCH] [Ref] Code simplification - remove conditional chunk All this calculation of component is only to insert it into an error messaage that we don't expect to see (ie it's an 'unknown error' error message, not an anticipated one. Given that, it's hard to see why we would use so many lines of code to calculate it --- CRM/Activity/BAO/Activity.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 40f6fdc906..ac7cac12fd 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -1699,16 +1699,10 @@ WHERE activity.id IN ($activityIds)"; $params = [] ) { $date = date('YmdHis'); - if ($activity->__table == 'civicrm_membership') { - $component = 'Membership'; + if ($activity->__table === 'civicrm_participant' && $activityType !== 'Email') { + $activityType = 'Event Registration'; } - elseif ($activity->__table == 'civicrm_participant') { - if ($activityType != 'Email') { - $activityType = 'Event Registration'; - } - $component = 'Event'; - } - elseif ($activity->__table == 'civicrm_contribution') { + if ($activity->__table == 'civicrm_contribution') { // create activity record only for Completed Contributions $contributionCompletedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); if ($activity->contribution_status_id != $contributionCompletedStatusId) { @@ -1718,7 +1712,7 @@ WHERE activity.id IN ($activityIds)"; } $params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Scheduled'); } - $activityType = $component = 'Contribution'; + $activityType = 'Contribution'; // retrieve existing activity based on source_record_id and activity_type if (empty($params['id'])) { @@ -1772,7 +1766,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')) { - throw new CRM_Core_Exception("Failed creating Activity for $component of id {$activity->id}"); + throw new CRM_Core_Exception("Failed creating Activity of type $activityType for entity id {$activity->id}"); } } -- 2.25.1