CRM-15141 - Fill smart group cache if empty
authorColeman Watts <coleman@civicrm.org>
Fri, 22 Aug 2014 15:49:33 +0000 (16:49 +0100)
committerColeman Watts <coleman@civicrm.org>
Fri, 22 Aug 2014 15:49:33 +0000 (16:49 +0100)
CRM/Contact/BAO/GroupContactCache.php
CRM/Group/Page/Group.php

index 8ffeb2da1345347975c79d071ba829a444acf491..a88d317325675d0aa44f7623b0036b4d1ed86331 100644 (file)
@@ -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
    */
index 545e3150d33f9c3b08184a59f49e4ebd398c904d..c0d6ef5ae732047ca4f54549477a59d3f0d5ec06 100644 (file)
@@ -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();
   }