From 520bca8e9e09b776de942470f297b4f2192455d1 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 22 Aug 2014 16:49:33 +0100 Subject: [PATCH] CRM-15141 - Fill smart group cache if empty --- CRM/Contact/BAO/GroupContactCache.php | 9 +++++++++ CRM/Group/Page/Group.php | 3 +++ 2 files changed, 12 insertions(+) diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index 8ffeb2da13..a88d317325 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -190,6 +190,15 @@ AND g.refresh_date IS NULL } } + /** + * FIXME: This function should not be needed, because the cache table should not be getting truncated + */ + static function fillIfEmpty() { + if (!CRM_Core_DAO::singleValueQuery("SELECT COUNT(id) FROM civicrm_group_contact_cache")) { + self::loadAll(); + } + } + /** * @param $groupID */ diff --git a/CRM/Group/Page/Group.php b/CRM/Group/Page/Group.php index 545e3150d3..c0d6ef5ae7 100644 --- a/CRM/Group/Page/Group.php +++ b/CRM/Group/Page/Group.php @@ -149,6 +149,9 @@ class CRM_Group_Page_Group extends CRM_Core_Page_Basic { if (!empty($_GET['update_smart_groups'])) { CRM_Contact_BAO_GroupContactCache::loadAll(); } + else { + CRM_Contact_BAO_GroupContactCache::fillIfEmpty(); + } $this->search(); } -- 2.25.1