From ab4e1e523e67460b5a0e199ffb5f2abf2391fa03 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 6 May 2021 18:57:08 +1200 Subject: [PATCH] [Ref] remove redundant call to clearGroupContactCache This code does a clear on the cache and then calls the api which will eventually call load(). Load ALSO clears the cache so this seems redundant. However, there are a couple of places where add() is called from where it might serve to force the rebuild due to changes to group make up. In general we have switched to invalidating and letting the rebuild-on-demand do it's thing to allow things like crons or lack of need for the group to reduce to browser demand. So, I think that by switching to invalidating rather than rebuilding we can remove this potentially locky line from GroupContactCache::add() --- CRM/Contact/BAO/Group.php | 4 ++-- CRM/Contact/BAO/GroupContactCache.php | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 81feb0f2e3..48e5802ab2 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -472,7 +472,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { // update group contact cache for all parent groups $parentIds = CRM_Contact_BAO_GroupNesting::getParentGroupIds($group->id); foreach ($parentIds as $parentId) { - CRM_Contact_BAO_GroupContactCache::add($parentId); + CRM_Contact_BAO_GroupContactCache::invalidateGroupContactCache($parentId); } } @@ -486,7 +486,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } self::flushCaches(); - CRM_Contact_BAO_GroupContactCache::add($group->id); + CRM_Contact_BAO_GroupContactCache::invalidateGroupContactCache($group->id); if (!empty($params['id'])) { CRM_Utils_Hook::post('edit', 'Group', $group->id, $group); diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index 54f7738e9a..91e011c98b 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -149,7 +149,6 @@ AND ( foreach ($groupIDs as $groupID) { // first delete the current cache - self::clearGroupContactCache($groupID); $params = [['group', 'IN', [$groupID], 0, 0]]; // the below call updates the cache table as a byproduct of the query CRM_Contact_BAO_Query::apiQuery($params, ['contact_id'], NULL, NULL, 0, 0, FALSE); -- 2.25.1