From 5aeca8c68bc1c5bd88f22a5c76cf23a64f9dbc1e Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sun, 30 Jan 2022 10:44:07 +0000 Subject: [PATCH] Avoid PHP notices on activity form --- CRM/Activity/Form/Activity.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 819e2c7607..4845e864e1 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -364,13 +364,15 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { ); } + $activityTypeDescription = NULL; if ($this->_activityTypeId) { - // Set activity type name and description to template. list($this->_activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($this->_activityTypeId); - $this->assign('activityTypeName', $this->_activityTypeName); - $this->assign('activityTypeDescription', $activityTypeDescription); } + // Set activity type name and description to template. + $this->assign('activityTypeName', $this->_activityTypeName ?? FALSE); + $this->assign('activityTypeDescription', $activityTypeDescription ?? FALSE); + // set user context $urlParams = $urlString = NULL; $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this); @@ -1235,6 +1237,9 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { * For the moment this is just pulled from preProcess */ public function assignActivityType() { + // Default array with required key for Smarty template + $activityTypeNameAndLabel = ['machineName' => FALSE]; + if ($this->_activityTypeId) { $activityTypeDisplayLabels = $this->getActivityTypeDisplayLabels(); if ($activityTypeDisplayLabels[$this->_activityTypeId]) { @@ -1242,7 +1247,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { // At the moment this is duplicating other code in this section, but refactoring in small steps. $activityTypeObj = new CRM_Activity_BAO_ActivityType($this->_activityTypeId); - $this->assign('activityTypeNameAndLabel', $activityTypeObj->getActivityType()); + $activityTypeNameAndLabel = $activityTypeObj->getActivityType(); } // Set title. if (isset($activityTypeDisplayLabels)) { @@ -1262,6 +1267,8 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { } } } + + $this->assign('activityTypeNameAndLabel', $activityTypeNameAndLabel); } } -- 2.25.1