commit f6d30b871c54a85433cb0677db777932e33e1ba1 Author: sun Date: Tue Jan 28 16:47:39 2014 +0100 Removed all GlobalConfig singleton changes. → [#2183591] diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 1b8c749..932dd4a 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -10,7 +10,6 @@ use Drupal\Core\DrupalKernel; use Drupal\Core\Database\Database; use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\Core\Config\GlobalConfig; use Drupal\Core\Utility\Title; use Drupal\Core\Utility\Error; use Symfony\Component\ClassLoader\ApcClassLoader; @@ -551,9 +550,6 @@ function drupal_settings_initialize() { // Initialize Settings. new Settings($settings); - // Initialize global Config overrides. - GlobalConfig::getInstance()->setConfig($config); - $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on'; if (isset($base_url)) { @@ -2099,7 +2095,7 @@ function drupal_valid_test_ua($new_prefix = NULL) { * The simpletest prefix. */ function _drupal_load_test_overrides($test_prefix) { - global $conf, $config_directories; + global $conf, $config_directories, $config; // Do not use the parent site's config directories. Use only the child site's. // @see \Drupal\simpletest\TestBase::prepareConfigDirectories() @@ -2113,7 +2109,6 @@ function _drupal_load_test_overrides($test_prefix) { $filename = conf_path() . '/files/' . $path_prefix . '/settings.php'; if (file_exists($filename)) { $settings = settings()->getAll(); - $config = GlobalConfig::getInstance()->getAll(); $conf_path = &drupal_static('conf_path'); // This can override $config, $conf_path, $settings, and $config_directories. include $filename; @@ -2121,8 +2116,6 @@ function _drupal_load_test_overrides($test_prefix) { // @see conf_path() $settings['simpletest_conf_path'] = $conf_path; new Settings($settings); - // Apply $config overrides. - GlobalConfig::getInstance()->setConfig($config); } } diff --git a/core/lib/Drupal/Core/Config/GlobalConfig.php b/core/lib/Drupal/Core/Config/GlobalConfig.php deleted file mode 100644 index 9d29ed6..0000000 diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php index 4d69e8d..31edcea 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php @@ -49,7 +49,7 @@ function testConfOverride() { $overrides['config_test.system']['foo'] = 'overridden'; $overrides['config_test.system']['baz'] = 'injected'; $overrides['config_test.system']['404'] = 'derp'; - $this->globalConfig->setConfig($overrides); + $GLOBALS['config'] = $overrides; $this->installConfig(array('config_test')); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index bb3213f..50c04ca 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -11,7 +11,6 @@ use Drupal\Core\Database\Database; use Drupal\Component\Utility\Settings; use Drupal\Core\Config\ConfigImporter; -use Drupal\Core\Config\GlobalConfig; use Drupal\Core\Config\StorageComparer; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Database\ConnectionNotDefinedException; @@ -86,18 +85,6 @@ protected $skipClasses = array(__CLASS__ => TRUE); /** - * Test-specific global configuration override values. - * - * @var array - */ - protected $configOverrides = array(); - - /** - * @var \Drupal\Core\Config\GlobalConfig - */ - protected $globalConfig; - - /** * TRUE if verbose debugging is enabled. * * @var boolean @@ -951,11 +938,9 @@ private function prepareEnvironment() { drupal_valid_test_ua($this->databasePrefix); } - $this->globalConfig = GlobalConfig::getInstance(); - // Backup current in-memory configuration. $this->originalSettings = settings()->getAll(); - $this->originalConfig = $this->globalConfig->getAll(); + $this->originalConfig = $GLOBALS['config']; // Backup statics and globals. $this->originalContainer = clone \Drupal::getContainer(); @@ -1068,14 +1053,7 @@ private function prepareEnvironment() { $conf = array(); // Remove all configuration overrides. - $this->globalConfig->setConfig(array()); - - // Apply global configuration override values. - foreach ($this->configOverrides as $config_name => $config_values) { - foreach ($config_values as $key => $value) { - $this->globalConfig->set($config_name, $key, $value); - } - } + $GLOBALS['config'] = array(); drupal_set_time_limit($this->timeLimit); } @@ -1211,7 +1189,7 @@ private function restoreEnvironment() { drupal_static_reset(); // Restore original in-memory configuration. - $this->globalConfig->setConfig($this->originalConfig); + $GLOBALS['config'] = $this->originalConfig; new Settings($this->originalSettings); // Restore original statics and globals. @@ -1231,9 +1209,6 @@ private function restoreEnvironment() { if (isset($this->originalPrefix)) { drupal_valid_test_ua($this->originalPrefix); } - else { - drupal_valid_test_ua(FALSE); - } // Restore original shutdown callbacks. $callbacks = &drupal_register_shutdown_function(); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 0aeea49..a385cc9 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -719,10 +719,6 @@ protected function setUp() { // Backup the currently running Simpletest batch. $this->originalBatch = batch_get(); - // Add the parent profile's search path to the child site's search paths. - // @see drupal_system_listing() - $this->globalConfig->set('simpletest.settings', 'parent_profile', $this->originalProfile); - // Define information about the user 1 account. $this->root_user = new UserSession(array( 'uid' => 1, @@ -736,9 +732,9 @@ protected function setUp() { $batch = array(); $this->settingsSet('file_public_path', $this->public_files_directory); - $this->globalConfig->set('system.file', 'path.private', $this->private_files_directory); - $this->globalConfig->set('system.file', 'path.temporary', $this->temp_files_directory); - $this->globalConfig->set('locale.settings', 'translation.path', $this->translation_files_directory); + $GLOBALS['config']['system.file']['path']['private'] = $this->private_files_directory; + $GLOBALS['config']['system.file']['path']['temporary'] = $this->temp_files_directory; + $GLOBALS['config']['locale.settings']['translation']['path'] = $this->translation_files_directory; // Execute the non-interactive installer. require_once DRUPAL_ROOT . '/core/includes/install.core.inc'; @@ -748,9 +744,13 @@ protected function setUp() { // Set the install_profile so that web requests to the requests to the child // site have the correct profile. - $settings['settings']['install_profile'] = (object) array( - 'value' => $this->profile, - 'required' => TRUE, + $settings = array( + 'settings' => array( + 'install_profile' => (object) array( + 'value' => $this->profile, + 'required' => TRUE, + ), + ), ); $this->writeSettings($settings); // Override install profile in Settings to so the correct profile is used by diff --git a/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerLanguageTest.php b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerLanguageTest.php index f489ddb..4f720d6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerLanguageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerLanguageTest.php @@ -25,7 +25,7 @@ public static function getInfo() { function setUp() { // Override the installation translations directory path. - $this->configOverrides['locale.settings']['translation.path'] = drupal_get_path('module', 'simpletest') . '/files/translations'; + $GLOBALS['config']['locale.settings']['translation']['path'] = drupal_get_path('module', 'simpletest') . '/files/translations'; parent::setUp(); } @@ -43,7 +43,7 @@ function testInstallerTranslationFiles() { 'it' => array(), ); - $file_translation = new FileTranslation($this->configOverrides['locale.settings']['translation.path']); + $file_translation = new FileTranslation($GLOBALS['config']['locale.settings']['translation']['path']); foreach ($expected_translation_files as $langcode => $files_expected) { $files_found = $file_translation->findTranslationFiles($langcode); $this->assertTrue(count($files_found) == count($files_expected), format_string('@count installer languages found.', array('@count' => count($files_expected)))); diff --git a/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php index 4db40f5..d4a2f36 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php @@ -34,13 +34,6 @@ protected function setUp() { $this->isInstalled = FALSE; - // Remove all configuration overrides. - $this->globalConfig->setConfig(array()); - - $this->globalConfig->set('system.file', 'path.private', $this->private_files_directory); - $this->globalConfig->set('system.file', 'path.temporary', $this->temp_files_directory); - $this->globalConfig->set('locale.settings', 'translation.path', $this->translation_files_directory); - $settings['conf_path'] = (object) array( 'value' => $this->public_files_directory, 'required' => TRUE, diff --git a/core/modules/system/lib/Drupal/system/Tests/InstallerTest.php b/core/modules/system/lib/Drupal/system/Tests/InstallerTest.php index de1375c..e788a6f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/InstallerTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/InstallerTest.php @@ -34,12 +34,6 @@ protected function setUp() { $this->isInstalled = FALSE; - // Remove all configuration overrides. - $this->globalConfig->setConfig(array()); - - $this->globalConfig->set('system.file', 'path.private', $this->private_files_directory); - $this->globalConfig->set('system.file', 'path.temporary', $this->temp_files_directory); - $this->globalConfig->set('locale.settings', 'translation.path', $this->translation_files_directory); $settings['conf_path'] = (object) array( 'value' => $this->public_files_directory, diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 7f478da..d25c7f7 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -330,12 +330,11 @@ function system_requirements($phase) { // conf_path() cache must also be reset in this case. $directories[] = conf_path(FALSE, TRUE) . '/files'; } - $config = \Drupal::config('system.file'); - if ($config->get('path.private')) { - $directories[] = $config->get('path.private'); + if (!empty($GLOBALS['config']['system.file']['path']['private'])) { + $directories[] = $GLOBALS['config']['system.file']['path']['private']; } - if ($config->get('path.temporary')) { - $directories[] = $config->get('path.temporary'); + if (!empty($GLOBALS['config']['system.file']['path.temporary'])) { + $directories[] = $GLOBALS['config']['system.file']['path']['temporary']; } else { // If the temporary directory is not overridden use an appropriate commit 6cfed15d89b02147704b86a849f13b88ec7bd9a2 Author: sun Date: Tue Jan 28 16:52:27 2014 +0100 Updated for new Config override architecture. diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index 3dcf661..32a3411 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -105,8 +105,6 @@ public function getOverrideState() { * {@inheritdoc} */ public function get($name) { - global $conf; - if ($config = $this->loadMultiple(array($name))) { return $config[$name]; } @@ -139,8 +137,8 @@ public function get($name) { $this->cache[$cache_key]->setModuleOverride($module_overrides[$name]); } // Apply any settings.php overrides. - if (isset($conf[$name])) { - $this->cache[$cache_key]->setSettingsOverride($conf[$name]); + if (isset($GLOBALS['config'][$name])) { + $this->cache[$cache_key]->setSettingsOverride($GLOBALS['config'][$name]); } } } @@ -152,8 +150,6 @@ public function get($name) { * {@inheritdoc} */ public function loadMultiple(array $names) { - global $conf; - $list = array(); foreach ($names as $key => $name) { @@ -205,8 +201,8 @@ public function loadMultiple(array $names) { if (isset($module_overrides[$name])) { $this->cache[$cache_key]->setModuleOverride($module_overrides[$name]); } - if (isset($conf[$name])) { - $this->cache[$cache_key]->setSettingsOverride($conf[$name]); + if (isset($GLOBALS['config'][$name])) { + $this->cache[$cache_key]->setSettingsOverride($GLOBALS['config'][$name]); } } $list[$name] = $this->cache[$cache_key];