From c9dbc47c1a676a05908675c9fe5a0b11f4562a79 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Mon, 21 Nov 2016 15:44:52 +1300 Subject: [PATCH] CRM-19672 - fix Settings code wierdness in some circumstances CRM-19672 remove test that calls removed functions. The point of the test (& the function) was to cope with the settings stored in which no longer exist --- CRM/Core/BAO/Domain.php | 35 +--------------------------- CRM/Core/BAO/Setting.php | 7 ------ tests/phpunit/api/v3/SettingTest.php | 21 ----------------- 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index 1bfd8e7e9896..6b1f6cf2db55 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -69,7 +69,7 @@ public static function retrieve(&$params, &$defaults) { * * @return CRM_Core_BAO_Domain|null */ - public static function &getDomain($reset = NULL) { + public static function getDomain($reset = NULL) { static $domain = NULL; if (!$domain || $reset) { $domain = new CRM_Core_BAO_Domain(); @@ -81,39 +81,6 @@ public static function &getDomain($reset = NULL) { return $domain; } - /** - * Change active domain (ie. to perform a temporary action) such as changing - * config for all domains - * - * Switching around the global domain variable is very risky business. This - * is ONLY used as a hack to allow CRM_Core_BAO_Setting::setItems to manipulate - * the civicrm_domain.config_backend in multiple domains. When/if config_backend - * goes away, this hack should be removed. - * - * @param int $domainID - * Id for domain you want to set as current. - * @deprecated - * @see http://issues.civicrm.org/jira/browse/CRM-11204 - */ - public static function setDomain($domainID) { - CRM_Core_Config::domainID($domainID); - self::getDomain($domainID); - CRM_Core_Config::singleton(TRUE, TRUE); - } - - /** - * Reset domain to default (ie. as loaded from settings). This is the - * counterpart to CRM_Core_BAO_Domain::setDomain. - * - * @deprecated - * @see CRM_Core_BAO_Domain::setDomain - */ - public static function resetDomain() { - CRM_Core_Config::domainID(NULL, TRUE); - self::getDomain(NULL, TRUE); - CRM_Core_Config::singleton(TRUE, TRUE); - } - /** * @param bool $skipUsingCache * diff --git a/CRM/Core/BAO/Setting.php b/CRM/Core/BAO/Setting.php index 30490cb85833..3324f43bf5d2 100644 --- a/CRM/Core/BAO/Setting.php +++ b/CRM/Core/BAO/Setting.php @@ -120,16 +120,10 @@ public static function getItems(&$params, $domains = NULL, $settingsToReturn) { if (!empty($settingsToReturn) && !is_array($settingsToReturn)) { $settingsToReturn = array($settingsToReturn); } - $reloadConfig = FALSE; $fields = $result = array(); $fieldsToGet = self::validateSettingsInput(array_flip($settingsToReturn), $fields, FALSE); foreach ($domains as $domainID) { - if ($domainID != CRM_Core_Config::domainID()) { - $reloadConfig = TRUE; - CRM_Core_BAO_Domain::setDomain($domainID); - } - $config = CRM_Core_Config::singleton($reloadConfig, $reloadConfig); $result[$domainID] = array(); foreach ($fieldsToGet as $name => $value) { $contactID = CRM_Utils_Array::value('contact_id', $params); @@ -140,7 +134,6 @@ public static function getItems(&$params, $domains = NULL, $settingsToReturn) { $result[$domainID][$name] = $setting; } } - CRM_Core_BAO_Domain::resetDomain(); } return $result; } diff --git a/tests/phpunit/api/v3/SettingTest.php b/tests/phpunit/api/v3/SettingTest.php index cc0d3beb04a3..ac46677cad42 100644 --- a/tests/phpunit/api/v3/SettingTest.php +++ b/tests/phpunit/api/v3/SettingTest.php @@ -363,27 +363,6 @@ public function testGetExtensionSetting() { $this->assertEquals('keyset', $result); } - /** - * Setting api should set & fetch settings stored in config as well as those in settings table - */ - public function testSetConfigSetting() { - $config = CRM_Core_Config::singleton(); - $this->assertFalse($config->debug == 1); - - $params = array( - 'domain_id' => $this->_domainID2, - 'debug_enabled' => 1, - ); - $result = $this->callAPISuccess('setting', 'create', $params); - - $this->assertEquals(1, Civi::settings($this->_domainID2)->get('debug_enabled')); - - CRM_Core_BAO_Domain::setDomain($this->_domainID2); - $config = CRM_Core_Config::singleton(TRUE, TRUE); - CRM_Core_BAO_Domain::resetDomain(); - $this->assertEquals(1, $config->debug); - } - /** * Setting api should set & fetch settings stored in config as well as those in settings table */