From db2d6c10bc52caecf42346f83fd2b005f9380232 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 21 Mar 2020 15:32:06 -0400 Subject: [PATCH] Fix undefined index warning in SavedSearch api --- api/v3/SavedSearch.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/api/v3/SavedSearch.php b/api/v3/SavedSearch.php index 1381022019..ca01c6fc4e 100644 --- a/api/v3/SavedSearch.php +++ b/api/v3/SavedSearch.php @@ -100,16 +100,19 @@ function civicrm_api3_saved_search_get($params) { } /** - * This function unserializes the form_values in an SavedSearch API result. + * Unserialize the form_values field in SavedSearch API results. + * + * Note: APIv4 handles serialization automatically based on metadata. * * @param array $result API result to be cleaned up. */ function _civicrm_api3_saved_search_result_cleanup(&$result) { if (isset($result['values']) && is_array($result['values'])) { - // Only clean up the values if there are values. (A getCount operation - // for example does not return values.) + // Only run if there are values (getCount for example does not return values). foreach ($result['values'] as $key => $value) { - $result['values'][$key]['form_values'] = \CRM_Utils_String::unserialize($value['form_values']); + if (isset($value['form_values'])) { + $result['values'][$key]['form_values'] = CRM_Utils_String::unserialize($value['form_values']); + } } } } -- 2.25.1