From d666ca085c68c57630f266c41906fe90089722f5 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Mon, 30 May 2016 10:19:05 +1200 Subject: [PATCH] CRM-18692 issue warning about empty smart group cache rather than crash the server --- CRM/Contact/BAO/GroupContactCache.php | 11 ----------- CRM/Group/Page/Group.php | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index dba6976fc1..2ba71e2d77 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -210,17 +210,6 @@ AND g.refresh_date IS NULL } } - /** - * Fill the group contact cache if it is empty. - * - * Do this by the expensive operation of loading all groups. Call sparingly. - */ - public static function fillIfEmpty() { - if (!CRM_Core_DAO::singleValueQuery("SELECT COUNT(id) FROM civicrm_group_contact_cache")) { - self::loadAll(); - } - } - /** * Build the smart group cache for a given group. * diff --git a/CRM/Group/Page/Group.php b/CRM/Group/Page/Group.php index 6d64276319..56468ce248 100644 --- a/CRM/Group/Page/Group.php +++ b/CRM/Group/Page/Group.php @@ -143,8 +143,8 @@ 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(); + elseif (!CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_group_contact_cache LIMIT 1")) { + CRM_Core_Session::setStatus(ts('Count data for smart groups is not currently calculated. You may click Update Smart Groups to generate it. Be aware this can cause significant server load')); } $this->search(); -- 2.25.1