From 71e7af08739378c46d56125a6047515fa1a00d0f Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Mon, 5 Jun 2023 15:57:28 -0400 Subject: [PATCH] Reverted changes by Davet, hack to disable cache clearing. We currently use deterministic caching: https://civicrm.org/blog/eileen/478-group-contact-cache-deadlocks-improvement --- CRM/Activity/BAO/Activity.php | 3 +-- CRM/Contact/BAO/Contact.php | 9 +-------- CRM/Contact/BAO/GroupContact.php | 24 ++---------------------- CRM/Event/BAO/Participant.php | 4 +--- CRM/Member/BAO/Membership.php | 3 +-- 5 files changed, 6 insertions(+), 37 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index d0c2cdd4c5..69442988d8 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -520,8 +520,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { } } - // reset the group contact cache since smart groups might be affected due to this - // CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); + CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); // Add to case if (isset($params['case_id'])) { diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 55fab61514..c9c9dc964c 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -394,14 +394,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact implements Civi\Co 'name' ); - //if (!$config->doNotResetCache) { - // Note: doNotResetCache flag is currently set by import contact process and merging, - // since resetting and - // rebuilding cache could be expensive (for many contacts). We might come out with better - // approach in future. - // HACK: Dave did this due to many donations and other requests failing due to acl_cache table locks (similar to what Dave disabled) - //CRM_Contact_BAO_Contact_Utils::clearContactCaches(); - //} + CRM_Contact_BAO_Contact_Utils::clearContactCaches(); if ($invokeHooks) { if ($isEdit) { diff --git a/CRM/Contact/BAO/GroupContact.php b/CRM/Contact/BAO/GroupContact.php index 53f92a6826..22d8902d54 100644 --- a/CRM/Contact/BAO/GroupContact.php +++ b/CRM/Contact/BAO/GroupContact.php @@ -135,11 +135,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact implemen $result = self::bulkAddContactsToGroup($contactIds, $groupId, $method, $status, $tracking); CRM_Contact_BAO_GroupContactCache::invalidateGroupContactCache($groupId); - - // reset the group contact cache for all group(s) - // if this group is being used as a smart group - // HACK: Dave had to disable an earlier version of this, but no longer is upstream! - //CRM_Contact_BAO_Contact_Utils::clearContactCaches(); + CRM_Contact_BAO_Contact_Utils::clearContactCaches(); CRM_Utils_Hook::post('create', 'GroupContact', $groupId, $contactIds); @@ -241,23 +237,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact implemen } } - // also reset the acl cache - $config = CRM_Core_Config::singleton(); - if (!$config->doNotResetCache) { - // HACK: Dave commented this out on 12/09/2014 due to lock wait timeouts on the acl cache that caused donations to fail. - //CRM_ACL_BAO_Cache::resetCache(); - } - - // reset the group contact cache for all group(s) - // if this group is being used as a smart group - // @todo consider what to do here - it feels like we should either - // 1) just invalidate the specific group's cache(& perhaps any parents) & let cron do it's thing or - // possibly clear this specific groups cache, or just call opportunisticCacheFlush() - which would have the - // same effect as the remove call. The reservation about that is that it is no more aggressive for the group that - // we know is altered than for all the others, or perhaps, more the point with it's parents & groups that use it in - // their criteria. - // HACK: Dave had to disable this, too! (similar to what Dave disabled) - //CRM_Contact_BAO_Contact_Utils::clearContactCaches(); + CRM_Contact_BAO_Contact_Utils::clearContactCaches(); CRM_Utils_Hook::post($op, 'GroupContact', $groupId, $contactIds); diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 1bd9eba505..7d3758ea32 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -110,9 +110,7 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant implements \Ci $participantBAO->save(); - // reset the group contact cache for this group - // HACK: by davet - // CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); + CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); if (!empty($params['id'])) { CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO); diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 59d8d3a2d2..15ef6231bb 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -114,8 +114,7 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { CRM_Member_BAO_MembershipLog::add($membershipLog); // reset the group contact cache since smart groups might be affected due to this - // HACK: a new fragrance by davet - // CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); + CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); $allStatus = CRM_Member_BAO_Membership::buildOptions('status_id', 'get'); $activityParams = [ -- 2.25.1