Commit e28bf654 authored by totten's avatar totten

(#217) PrevNext - Add settings for admin to choose backend

The auto-detection is a good default policy.  However, this is new
functionality.  If some bug gets through the review/RC cycles, then this
option provides an escape path.
parent 514813c0
......@@ -56,6 +56,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
'dedupe_default_limit' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'remote_profile_submissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'allow_alert_autodismissal' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'prevNextBackend' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
);
public $_uploadMaxSize;
......@@ -77,6 +78,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
'recentItemsMaxCount',
'recentItemsProviders',
'dedupe_default_limit',
'prevNextBackend',
));
}
......
......@@ -483,4 +483,18 @@ AND c.created_date < date_sub( NOW( ), INTERVAL %2 day )
}
}
/**
* Get a list of available backend services.
*
* @return array
* Array(string $id => string $label).
*/
public static function getPrevNextBackends() {
return [
'default' => ts('Default (Auto-detect)'),
'sql' => ts('SQL'),
'redis' => ts('Redis'),
];
}
}
......@@ -441,11 +441,17 @@ class Container {
* @return \CRM_Core_PrevNextCache_Interface
*/
public static function createPrevNextCache($container) {
$cacheDriver = \CRM_Utils_Cache::getCacheDriver();
$service = 'prevnext.driver.' . strtolower($cacheDriver);
return $container->has($service)
? $container->get($service)
: $container->get('prevnext.driver.sql');
$setting = \Civi::settings()->get('prevNextBackend');
if ($setting === 'default') {
$cacheDriver = \CRM_Utils_Cache::getCacheDriver();
$service = 'prevnext.driver.' . strtolower($cacheDriver);
return $container->has($service)
? $container->get($service)
: $container->get('prevnext.driver.sql');
}
else {
return $container->get('prevnext.driver.' . $setting);
}
}
public static function createCacheConfig() {
......
......@@ -197,6 +197,27 @@ return array(
'description' => 'If set, this will be the default profile used for contact search.',
'help_text' => NULL,
),
'prevNextBackend' => array(
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'prevNextBackend',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
'html_attributes' => array(
//'class' => 'crm-select2',
),
'default' => 'default',
'add' => '5.6',
'title' => 'PrevNext Cache',
'is_domain' => 1,
'is_contact' => 0,
'pseudoconstant' => array(
'callback' => 'CRM_Core_BAO_PrevNextCache::getPrevNextBackends',
),
'description' => 'When performing a search, how should the search-results be cached?',
'help_text' => '',
),
'searchPrimaryDetailsOnly' => array(
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment