From c2f2bbe6582dc2812833300506e570f6f76fbdc6 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 2 Jun 2014 21:21:05 -0700 Subject: [PATCH] api_v3_CaseType - Tweak edge cases --- CRM/Case/BAO/CaseType.php | 4 +++- api/v3/CaseType.php | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CRM/Case/BAO/CaseType.php b/CRM/Case/BAO/CaseType.php index 2fef389b8b..00e0547e97 100644 --- a/CRM/Case/BAO/CaseType.php +++ b/CRM/Case/BAO/CaseType.php @@ -72,7 +72,9 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { } // function to format definition column - $params['definition'] = self::convertDefinitionToXML($params['name'], $params['definition']); + if (isset($params['definition']) && is_array($params['definition'])) { + $params['definition'] = self::convertDefinitionToXML($params['name'], $params['definition']); + } $caseTypeDAO->copyValues($params); return $caseTypeDAO->save(); diff --git a/api/v3/CaseType.php b/api/v3/CaseType.php index ed2aa8c0b6..d046c5a20c 100644 --- a/api/v3/CaseType.php +++ b/api/v3/CaseType.php @@ -83,10 +83,12 @@ function civicrm_api3_case_type_get($params) { */ function _civicrm_api3_case_type_get_formatResult(&$result) { foreach ($result['values'] as $key => $caseType) { - $definition = CRM_Case_BAO_CaseType::convertXmlToDefinition( - CRM_Case_XMLRepository::singleton()->retrieve($caseType['name']) - ); - $result['values'][$key]['definition'] = $definition; + $xml = CRM_Case_XMLRepository::singleton()->retrieve($caseType['name']); + if ($xml) { + $result['values'][$key]['definition'] = CRM_Case_BAO_CaseType::convertXmlToDefinition($xml); + } else { + $result['values'][$key]['definition'] = array(); + } } return $result; } -- 2.25.1