Add domain id to cachestring
authoreileen <eileen@fuzion.co.nz>
Thu, 11 Apr 2013 11:12:31 +0000 (23:12 +1200)
committereileen <eileen@fuzion.co.nz>
Fri, 12 Apr 2013 05:40:45 +0000 (17:40 +1200)
CRM/Core/BAO/ConfigSetting.php
CRM/Core/BAO/Setting.php
CRM/Core/Config.php
tools/bin/scripts/memcache.php

index d912f974ea9cee5d37ff96bc97d252c598e0902a..b17b6bd326e872554125f371959e5360241d4796 100644 (file)
@@ -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);
   }
 
index 068cf3e916293d6eeb25438add994b4b8d4343e8..4d75ee43fc7541a4cb44dae35f7af1b4c7659a52 100644 (file)
@@ -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;
index e91458dbf4b94dea3730cb24f873d6a48394ef71..3356f009743c654929c3ef5e4671ce633b8f552d 100644 (file)
@@ -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
index 9436fd3a3037f5196801c114f8c8c9d51e11ad7f..6a29cc494a9e5da3b6fe0d6d8ceabffaebc5b1ff 100644 (file)
@@ -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()));