From 791a8dc46f14297748195bea584c5d7066980190 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 7 Aug 2017 12:20:41 +0100 Subject: [PATCH] contact_id is optional when updating case, this change allows existing Case unit tests to pass --- api/v3/Case.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/v3/Case.php b/api/v3/Case.php index b51bfe335d..d923ebd2f6 100644 --- a/api/v3/Case.php +++ b/api/v3/Case.php @@ -39,11 +39,13 @@ * @param array $params * * @code - * //REQUIRED: + * //REQUIRED for create: * 'case_type_id' => int OR * 'case_type' => str (provide one or the other) * 'contact_id' => int // case client * 'subject' => str + * //REQUIRED for update: + * 'id' => case Id * * //OPTIONAL * 'medium_id' => int // see civicrm option values for possibilities @@ -123,9 +125,11 @@ function civicrm_api3_case_create($params) { throw new API_Exception('Case not created. Please check input params.'); } - foreach ((array) $params['contact_id'] as $cid) { - $contactParams = array('case_id' => $caseBAO->id, 'contact_id' => $cid); - CRM_Case_BAO_CaseContact::create($contactParams); + if (isset($params['contact_id'])) { + foreach ((array) $params['contact_id'] as $cid) { + $contactParams = array('case_id' => $caseBAO->id, 'contact_id' => $cid); + CRM_Case_BAO_CaseContact::create($contactParams); + } } if (!isset($params['id'])) { -- 2.25.1