From: Donald A. Lobo Date: Thu, 30 May 2013 00:20:28 +0000 (-0700) Subject: CRM-12466 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cc13551d70102083301ab9bb83a9dd97d7364995;p=civicrm-core.git CRM-12466 ---------------------------------------- * CRM-12466: Group listings don't load http://issues.civicrm.org/jira/browse/CRM-12466 --- diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index 33f59d79c0..3268a99c27 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -317,6 +317,18 @@ WHERE id = %1 if (array_key_exists($groupID, self::$_alreadyLoaded) && !$fresh) { return; } + + // grab a lock so other processes dont compete and do the same query + $lockName = "civicrm.group.{$groupID}"; + $lock = new CRM_Core_Lock($lockName); + if (!$lock->isAcquired()) { + // this can cause inconsistent results since we dont know if the other process + // will fill up the cache before our calling routine needs it. + // however this routine does not return the status either, so basically + // its a "lets return and hope for the best" + return; + } + self::$_alreadyLoaded[$groupID] = 1; $sql = NULL; $idName = 'id'; @@ -354,9 +366,9 @@ WHERE id = %1 $query = new CRM_Contact_BAO_Query( $ssParams, $returnProperties, NULL, - FALSE, FALSE, 1, - TRUE, TRUE, - FALSE, + FALSE, FALSE, 1, + TRUE, TRUE, + FALSE, CRM_Utils_Array::value('display_relationship_type', $formValues), CRM_Utils_Array::value('operator', $formValues, 'AND') ); @@ -433,6 +445,8 @@ AND civicrm_group_contact.group_id = $groupID "; self::store($groupIDs, $values); } } + + $lock->release(); } static function smartGroupCacheTimeout() {