CRM-18692 issue warning about empty smart group cache rather than crash the server
authoreileenmcnaugton <eileen@fuzion.co.nz>
Sun, 29 May 2016 22:19:05 +0000 (10:19 +1200)
committerSeamus Lee <seamuslee001@gmail.com>
Wed, 3 Aug 2016 21:02:30 +0000 (07:02 +1000)
CRM/Contact/BAO/GroupContactCache.php
CRM/Group/Page/Group.php

index 817f4ede4083679cd3e14b1cff4a5bffba520db2..4a6021753ee254066ca8c30ddafc0af854008b21 100644 (file)
@@ -196,17 +196,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.
    *
index 987609b44a85a06eab91d2d5bd9b34e90e322e91..d0f6efddf37a7db3133b8e0d1c180f5bb8d51ef8 100644 (file)
@@ -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();