From d674c5f8a3e63859210f538390308eb4c9fc6687 Mon Sep 17 00:00:00 2001 From: Eileen Date: Fri, 13 Sep 2013 18:22:05 +1200 Subject: [PATCH] CRM-13234 api/v3/CustomField more cache clearing on custom field create --- api/v3/CustomField.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/v3/CustomField.php b/api/v3/CustomField.php index dad64832a9..6a41b74be2 100644 --- a/api/v3/CustomField.php +++ b/api/v3/CustomField.php @@ -74,12 +74,20 @@ function civicrm_api3_custom_field_create($params) { $params['option_weight'][$key] = $value['weight']; } } + $values = array(); $customField = CRM_Core_BAO_CustomField::create($params); - civicrm_api('custom_field', 'getfields', array('version' => 3, 'cache_clear' => 1)); _civicrm_api3_object_to_array_unique_fields($customField, $values[$customField->id]); + _civicrm_api3_custom_field_flush_static_caches(); return civicrm_api3_create_success($values, $params, 'custom_field', $customField); } +/** + * Flush static caches in functions that might have stored available custom fields + */ +function _civicrm_api3_custom_field_flush_static_caches(){ + civicrm_api('custom_field', 'getfields', array('version' => 3, 'cache_clear' => 1)); + CRM_Core_BAO_UFField::getAvailableFieldsFlat(TRUE); +} /** * Adjust Metadata for Create action * -- 2.25.1