Skip to content

Commit

Permalink
[REF] Slightly more logical order of code
Browse files Browse the repository at this point in the history
Just moves the lock check to the same area
  • Loading branch information
eileenmcnaughton committed May 20, 2021
1 parent 2b6d4ea commit d24c060
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions CRM/Contact/BAO/GroupContactCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,6 @@ public static function load($group, $force = FALSE) {

// 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.
Expand All @@ -398,6 +391,12 @@ public static function load($group, $force = FALSE) {
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.
Expand Down

0 comments on commit d24c060

Please sign in to comment.