From d24c0600037799c309af6d0c9b07c33edb626e19 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 21 May 2021 10:34:09 +1200 Subject: [PATCH] [REF] Slightly more logical order of code Just moves the lock check to the same area --- CRM/Contact/BAO/GroupContactCache.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index 643f206eff..229f54c8af 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -383,13 +383,6 @@ WHERE id IN ( $groupIDs ) // grab a lock so other processes don't compete and do the same query $lock = Civi::lockManager()->acquire("data.core.group.{$groupID}"); - - $groupContactsTempTable = CRM_Utils_SQL_TempTable::build() - ->setCategory('gccache') - ->setMemory(); - self::buildGroupContactTempTable([$groupID], $groupContactsTempTable); - $tempTable = $groupContactsTempTable->getName(); - if (!$lock->isAcquired()) { // this can cause inconsistent results since we don't know if the other process // will fill up the cache before our calling routine needs it. @@ -398,6 +391,12 @@ WHERE id IN ( $groupIDs ) return; } + $groupContactsTempTable = CRM_Utils_SQL_TempTable::build() + ->setCategory('gccache') + ->setMemory(); + self::buildGroupContactTempTable([$groupID], $groupContactsTempTable); + $tempTable = $groupContactsTempTable->getName(); + // Don't call clearGroupContactCache as we don't want to clear the cache dates // The will get updated by updateCacheTime() below and not clearing the dates reduces // the chance that loadAll() will try and rebuild at the same time. -- 2.25.1