From a1379c2c10953851dd309c6a4c16e39db0ae2fe3 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 1 Mar 2022 19:02:22 -0800 Subject: [PATCH] Refresh entity list after updating custom group (self_hook_*) Overview ---------------------------------------- The CustomGroups are used to generate virtual entities (if they set `is_multiple`). Toggling `is_multiple` should cause the virtual entity to be added or removed. Reproduction steps ---------------------------------------- 1. Create a custom data group. Leave default `is_multiple=0`. 2. View "API Explorer". Look for the virtual entity. (It's not there. Properly so.) 3. Edit custom data group. Change to `is_multiple=1`. 4. Reload "API Explorer". Look for the virtual entity. Before ---------------------------------------- The entity does not appear. You have to do a system-flush. After ---------------------------------------- The entity does appear. --- CRM/Core/BAO/CustomGroup.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index c00e866270..e5dbb35f71 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -18,7 +18,15 @@ /** * Business object for managing custom data groups. */ -class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { +class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup implements \Civi\Core\HookInterface { + + /** + * @param \Civi\Core\Event\PostEvent $e + * @see CRM_Utils_Hook::post() + */ + public static function self_hook_civicrm_post(\Civi\Core\Event\PostEvent $e): void { + Civi::cache('metadata')->flush(); + } /** * Takes an associative array and creates a custom group object. -- 2.25.1