Skip to content

Commit

Permalink
flushCaches should respect permitCacheFlushMode. Also flush caches wh…
Browse files Browse the repository at this point in the history
…ich have a NULL cache_date
  • Loading branch information
mattwire committed Sep 14, 2021
1 parent 5bc6e53 commit 8d8959e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions CRM/Contact/BAO/GroupContactCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ protected static function clearGroupContactCache($groupID): void {
* clear.
*/
protected static function flushCaches() {
if (!CRM_Core_Config::isPermitCacheFlushMode()) {
return;
}

try {
$lock = self::getLockForRefresh();
}
Expand All @@ -256,10 +260,12 @@ protected static function flushCaches() {
return;
}
$params = [1 => [self::getCacheInvalidDateTime(), 'String']];
$groupsDAO = CRM_Core_DAO::executeQuery("SELECT id FROM civicrm_group WHERE cache_date <= %1", $params);
$groupsToFlushSQL = 'SELECT group_id FROM civicrm_group_contact_cache gc INNER JOIN civicrm_group g
WHERE cache_date <= %1 OR cache_date IS NULL GROUP BY group_id';
$groupsDAO = CRM_Core_DAO::executeQuery($groupsToFlushSQL, $params);
$expiredGroups = [];
while ($groupsDAO->fetch()) {
$expiredGroups[] = $groupsDAO->id;
$expiredGroups[] = $groupsDAO->group_id;
}
if (!empty($expiredGroups)) {
$expiredGroups = implode(',', $expiredGroups);
Expand Down

0 comments on commit 8d8959e

Please sign in to comment.