From: Coleman Watts Date: Fri, 22 Aug 2014 15:49:33 +0000 (+0100) Subject: CRM-15141 - Fill smart group cache if empty X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=520bca8e9e09b776de942470f297b4f2192455d1;p=civicrm-core.git CRM-15141 - Fill smart group cache if empty --- 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(); }