CRM-16642 add setting & functions for opportunistic vs deterministic cache clearing
[civicrm-core.git] / CRM / Upgrade / Incremental / php / FourSeven.php
index 6a33eceda470d5564e6c68e5abf31014e43848da..c4be97e4a39393e8f33afab456322e931b7481e7 100644 (file)
@@ -208,6 +208,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
   public function upgrade_4_7_8($rev) {
     $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
     $this->addTask('Upgrade mailing foreign key constraints', 'upgradeMailingFKs');
+    $this->addSmartGroupRefreshOptions();
   }
 
   /*
@@ -690,4 +691,38 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
     return TRUE;
   }
 
+  /**
+   * CRM-16642 Add option for smart group refreshing.
+   *
+   * @param \CRM_Queue_TaskContext $ctx
+   *
+   * @return bool
+   */
+  public function addSmartGroupRefreshOptions(CRM_Queue_TaskContext $ctx) {
+    $optionGroupID = CRM_Core_BAO_OptionGroup::ensureOptionGroupExists(array(
+      'name' => 'smart_group_cache_refresh_mode',
+      'title' => ts('Mode for refreshing smart group cache'),
+      'description' => ts('This provides the option for the smart group cache setting'),
+      'is_reserved' => 1,
+    ));
+    CRM_Core_BAO_OptionValue::ensureOptionValueExists(array(
+      'option_group_id' => $optionGroupID,
+      'name' => 'opportunistic',
+      'label' => ts('Opportunistic'),
+      'description' => ts('Purge the cache in response to user actions'),
+      'is_active' => TRUE,
+      'filter' => 1,
+      'is_reserved' => 1,
+    ));
+    CRM_Core_BAO_OptionValue::ensureOptionValueExists(array(
+      'option_group_id' => $optionGroupID,
+      'name' => 'deterministic',
+      'label' => ts('Deterministic'),
+      'description' => ts('Only purge the cache on system jobs'),
+      'is_active' => TRUE,
+      'filter' => 1,
+      'is_reserved' => 1,
+    ));
+  }
+
 }