From 0e04f44e97fc67f6a93614b4de78a092573e8c09 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 11 Apr 2013 23:12:31 +1200 Subject: [PATCH] Add domain id to cachestring --- CRM/Core/BAO/ConfigSetting.php | 1 + CRM/Core/BAO/Setting.php | 12 ++++++++++-- CRM/Core/Config.php | 5 ++--- tools/bin/scripts/memcache.php | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CRM/Core/BAO/ConfigSetting.php b/CRM/Core/BAO/ConfigSetting.php index d912f974ea..b17b6bd326 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -53,6 +53,7 @@ class CRM_Core_BAO_ConfigSetting { self::add($params); $cache = CRM_Utils_Cache::singleton(); $cache->delete('CRM_Core_Config'); + $cache->delete('CRM_Core_Config' . CRM_Core_Config::domainID()); $config = CRM_Core_Config::singleton(TRUE, TRUE); } diff --git a/CRM/Core/BAO/Setting.php b/CRM/Core/BAO/Setting.php index 068cf3e916..4d75ee43fc 100644 --- a/CRM/Core/BAO/Setting.php +++ b/CRM/Core/BAO/Setting.php @@ -214,16 +214,23 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { * @access public */ static function getItems(&$params, $domains = null, $settingsToReturn) { + $originalDomain = CRM_Core_Config::domainID(); if (empty($domains)) { - $domains[] = CRM_Core_Config::domainID(); + $domains[] = $originalDomain; } if (!empty($settingsToReturn) && !is_array($settingsToReturn)) { $settingsToReturn = array($settingsToReturn); } - $config = CRM_Core_Config::singleton(); + $reloadConfig = FALSE; + $fields = $result = array(); $fieldsToGet = self::validateSettingsInput(array_flip($settingsToReturn), $fields, FALSE); foreach ($domains as $domain) { + CRM_Core_BAO_Domain::setDomain($domain); + if($domain != $originalDomain){ + $reloadConfig = TRUE; + } + $config = CRM_Core_Config::singleton($reloadConfig, $reloadConfig); $result[$domain] = array(); foreach ($fieldsToGet as $name => $value) { if(!empty($fields['values'][$name]['prefetch'])){ @@ -248,6 +255,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { // e.g for revert of fill actions $result[$domain][$name] = $setting; } + CRM_Core_BAO_Domain::resetDomain(); } } return $result; diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index e91458dbf4..3356f00974 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -184,8 +184,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { // first, attempt to get configuration object from cache $cache = CRM_Utils_Cache::singleton(); - self::$_singleton = $cache->get('CRM_Core_Config'); - + self::$_singleton = $cache->get('CRM_Core_Config' . CRM_Core_Config::domainID()); // if not in cache, fire off config construction if (!self::$_singleton) { self::$_singleton = new CRM_Core_Config; @@ -199,7 +198,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { // retrieve and overwrite stuff from the settings file self::$_singleton->setCoreVariables(); } - $cache->set('CRM_Core_Config', self::$_singleton); + $cache->set('CRM_Core_Config' . CRM_Core_Config::domainID(), self::$_singleton); } else { // we retrieve the object from memcache, so we now initialize the objects diff --git a/tools/bin/scripts/memcache.php b/tools/bin/scripts/memcache.php index 9436fd3a30..6a29cc494a 100644 --- a/tools/bin/scripts/memcache.php +++ b/tools/bin/scripts/memcache.php @@ -8,6 +8,6 @@ define('CIVICRM_USE_MEMCACHE', 1); $config = &CRM_Core_Config::singleton(); $cache = &CRM_Utils_Cache::singleton(); -$cache->set('CRM_Core_Config', $config); -CRM_Core_Error::debug('get', $cache->get('CRM_Core_Config')); +$cache->set('CRM_Core_Config' .CRM_Core_Config::domainID(), $config); +CRM_Core_Error::debug('get', $cache->get('CRM_Core_Config' . CRM_Core_Config::domainID())); -- 2.25.1