From d79a645b279a8edd6bb23e53403d8c893a65fa0b Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Thu, 28 Nov 2019 12:14:11 +0000 Subject: [PATCH] Issue #3097173 by alexpott, Berdir: Complete removal of $config_directories --- core/globals.api.php | 10 -- core/includes/install.core.inc | 2 +- core/lib/Drupal/Core/DrupalKernel.php | 2 +- core/lib/Drupal/Core/Site/Settings.php | 12 +-- .../Core/Test/FunctionalTestSetupTrait.php | 1 - core/modules/simpletest/src/TestBase.php | 5 +- core/modules/system/system.install | 26 ----- .../src/Functional/System/StatusTest.php | 2 +- ...ConfigDirectorySetNoDirectoryErrorTest.php | 2 +- .../InstallerExistingConfigDirectoryTest.php | 2 +- .../Core/DrupalKernel/DrupalKernelTest.php | 8 +- .../Drupal/Tests/Core/Site/SettingsTest.php | 102 ------------------ 12 files changed, 11 insertions(+), 163 deletions(-) diff --git a/core/globals.api.php b/core/globals.api.php index d19605bf6520..f480fc4f730c 100644 --- a/core/globals.api.php +++ b/core/globals.api.php @@ -59,16 +59,6 @@ */ global $config; -/** - * The location of file system directories used for site configuration data. - * - * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use - * \Drupal\Core\Site\Settings::get('config_sync_directory') instead. - * - * @see https://www.drupal.org/node/3018145 - */ -global $config_directories; - /** * Store settings and profile information during installation process. * diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 6643a10b8225..bbc0f32ddf8e 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -385,7 +385,7 @@ function install_begin_request($class_loader, &$install_state) { } $install_state['database_verified'] = install_verify_database_settings($site_path); // A valid settings.php has database settings and a hash_salt value. Other - // settings like config_directories will be checked by system_requirements(). + // settings will be checked by system_requirements(). $install_state['settings_verified'] = $install_state['database_verified'] && (bool) Settings::get('hash_salt', FALSE); // Install factory tables only after checking the database. diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index fe68ea41f44a..bc85ccd04c3d 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -1390,7 +1390,7 @@ protected function getHttpKernel() { protected function getConfigStorage() { if (!isset($this->configStorage)) { // The active configuration storage may not exist yet; e.g., in the early - // installer. Catch the exception thrown by config_get_config_directory(). + // installer so if an exception is thrown use a NullStorage. try { $this->configStorage = BootstrapConfigStorageFactory::get($this->classLoader); } diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index ad8713a7524c..e6b3cfa33c60 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -116,7 +116,7 @@ public static function getAll() { */ public static function initialize($app_root, $site_path, &$class_loader) { // Export these settings.php variables to the global namespace. - global $config_directories, $config; + global $config; $settings = []; $config = []; $databases = []; @@ -128,16 +128,6 @@ public static function initialize($app_root, $site_path, &$class_loader) { // Initialize Database. Database::setMultipleConnectionInfo($databases); - // For BC ensure the $config_directories global is set both in the global - // and settings. - if (!isset($settings['config_sync_directory']) && !empty($config_directories['sync'])) { - @trigger_error('$config_directories[\'sync\'] has moved to $settings[\'config_sync_directory\']. See https://www.drupal.org/node/3018145.', E_USER_DEPRECATED); - $settings['config_sync_directory'] = $config_directories['sync']; - } - elseif (isset($settings['config_sync_directory'])) { - $config_directories['sync'] = $settings['config_sync_directory']; - } - // Initialize Settings. new Settings($settings); } diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php index 1df7ccf99cc2..50fe122f908a 100644 --- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php @@ -653,7 +653,6 @@ protected function prepareEnvironment() { $this->container = NULL; // Unset globals. - unset($GLOBALS['config_directories']); unset($GLOBALS['config']); unset($GLOBALS['conf']); diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index 969e227041da..67c36b8ead15 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -1163,7 +1163,6 @@ private function prepareEnvironment() { \Drupal::unsetContainer(); // Unset globals. - unset($GLOBALS['config_directories']); unset($GLOBALS['config']); unset($GLOBALS['conf']); @@ -1276,8 +1275,8 @@ private function restoreEnvironment() { // Re-initialize original stream wrappers of the parent site. // This must happen after static variables have been reset and the original - // container and $config_directories are restored, as simpletest_log_read() - // uses the public stream wrapper to locate the error.log. + // container and settings are restored, as simpletest_log_read() uses the + // public stream wrapper to locate the error.log. $this->originalContainer->get('stream_wrapper_manager')->register(); if (isset($this->originalPrefix)) { diff --git a/core/modules/system/system.install b/core/modules/system/system.install index e0f57178a312..cbbb50b1050c 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -696,32 +696,6 @@ function system_requirements($phase) { ]; } - // Handle other configuration directories. This will be removed in Drupal 9. - // See https://www.drupal.org/node/3018145. - $bc_config_directories = isset($GLOBALS['config_directories']) ? $GLOBALS['config_directories'] : []; - unset($bc_config_directories['sync']); - foreach (array_keys(array_filter($bc_config_directories)) as $type) { - @trigger_error("Automatic creation of '$type' configuration directory will be removed from drupal:9.0.0. See https://www.drupal.org/node/3018145.", E_USER_DEPRECATED); - $directory = config_get_config_directory($type); - // If we're installing Drupal try and create the config sync directory. - if (!is_dir($directory) && $phase == 'install') { - \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); - } - if (!is_dir($directory)) { - if ($phase == 'install') { - $description = t('An automated attempt to create the directory %directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', ['%directory' => $directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']); - } - else { - $description = t('The directory %directory does not exist.', ['%directory' => $directory]); - } - $requirements['config directory ' . $type] = [ - 'title' => t('Configuration directory: %type', ['%type' => $type]), - 'description' => $description, - 'severity' => REQUIREMENT_ERROR, - ]; - } - } - $requirements['file system'] = [ 'title' => t('File system'), ]; diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php index 6d4cce4c7b0f..80ebaa124fef 100644 --- a/core/modules/system/tests/src/Functional/System/StatusTest.php +++ b/core/modules/system/tests/src/Functional/System/StatusTest.php @@ -63,7 +63,7 @@ public function testStatusPage() { // If a module is fully installed no pending updates exists. $this->assertNoText(t('Out of date')); - // The global $config_directories is not properly formed. + // The setting config_sync_directory is not properly formed. $this->assertRaw(t("Your %file file must define the %setting setting", ['%file' => $this->siteDirectory . '/settings.php', '%setting' => "\$settings['config_sync_directory']"])); // Set the schema version of update_test_postupdate to a lower version, so diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php index 38a08bf3b876..5a0f3248527f 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php @@ -5,7 +5,7 @@ use Drupal\Component\Utility\Crypt; /** - * Tests the installer when a config_directory set up but does not exist. + * Tests installation when a config_sync_directory is set up but does not exist. * * @group Installer */ diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php index eae925a62af2..41d7eac1730c 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php @@ -3,7 +3,7 @@ namespace Drupal\FunctionalTests\Installer; /** - * Tests the installer when a config_directory has already been set up. + * Tests installation when a config_sync_directory is exists and is set up. * * @group Installer */ diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php index aede46b3555d..e3b4d81a17a6 100644 --- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php @@ -17,11 +17,9 @@ class DrupalKernelTest extends KernelTestBase { * {@inheritdoc} */ protected function setUp() { - // DrupalKernel relies on global $config_directories and requires those - // directories to exist. Therefore, create the directories, but do not - // invoke KernelTestBase::setUp(), since that would set up further - // environment aspects, which would distort this test, because it tests - // the DrupalKernel (re-)building itself. + // Do not invoke KernelTestBase::setUp(), since that would set up further + // environment aspects, which would distort this test, because it tests the + // DrupalKernel (re-)building itself. $this->root = static::getDrupalRoot(); $this->bootEnvironment(); } diff --git a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php index c43bc99a527d..3736705c4d3d 100644 --- a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php +++ b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php @@ -5,7 +5,6 @@ use Drupal\Core\Site\Settings; use Drupal\Tests\Traits\ExpectDeprecationTrait; use Drupal\Tests\UnitTestCase; -use org\bovigo\vfs\vfsStream; /** * @coversDefaultClass \Drupal\Core\Site\Settings @@ -151,105 +150,4 @@ public function testGetInstanceReflection() { $settings->getInstance(); } - /** - * @runInSeparateProcess - * @group legacy - * @covers ::__construct - * @dataProvider configDirectoriesBcLayerProvider - */ - public function testConfigDirectoriesBcLayer($settings_file_content, $directory, $expect_deprecation) { - global $config_directories; - $class_loader = NULL; - - $vfs_root = vfsStream::setup('root'); - $sites_directory = vfsStream::newDirectory('sites')->at($vfs_root); - vfsStream::newFile('settings.php') - ->at($sites_directory) - ->setContent($settings_file_content); - - if ($expect_deprecation) { - $this->expectDeprecation('$config_directories[\'sync\'] has moved to $settings[\'config_sync_directory\']. See https://www.drupal.org/node/3018145.'); - } - - Settings::initialize(vfsStream::url('root'), 'sites', $class_loader); - $this->assertSame($directory, Settings::get('config_sync_directory')); - $this->assertSame($directory, $config_directories['sync']); - } - - /** - * Data provider for self::testConfigDirectoriesBcLayer(). - */ - public function configDirectoriesBcLayerProvider() { - $no_config_directories = <<<'EOD' -<?php -$settings['config_sync_directory'] = 'foo'; -EOD; - - $only_config_directories = <<<'EOD' -<?php -$config_directories['sync'] = 'bar'; -EOD; - - $both = <<<'EOD' -<?php -$settings['config_sync_directory'] = 'foo'; -$config_directories['sync'] = 'bar'; -EOD; - - return [ - 'Only $settings[\'config_sync_directory\']' => [ - $no_config_directories, - 'foo', - FALSE, - ], - 'Only $config_directories' => [$only_config_directories, 'bar', TRUE], - 'Both' => [$both, 'foo', FALSE], - ]; - } - - /** - * @runInSeparateProcess - * @group legacy - */ - public function testConfigDirectoriesBcLayerEmpty() { - global $config_directories; - $class_loader = NULL; - - $vfs_root = vfsStream::setup('root'); - $sites_directory = vfsStream::newDirectory('sites')->at($vfs_root); - vfsStream::newFile('settings.php')->at($sites_directory)->setContent(<<<'EOD' -<?php -$settings = []; -EOD - ); - - Settings::initialize(vfsStream::url('root'), 'sites', $class_loader); - $this->assertNull(Settings::get('config_sync_directory')); - $this->assertNull($config_directories); - } - - /** - * @runInSeparateProcess - * @group legacy - */ - public function testConfigDirectoriesBcLayerMultiple() { - global $config_directories; - $class_loader = NULL; - - $vfs_root = vfsStream::setup('root'); - $sites_directory = vfsStream::newDirectory('sites')->at($vfs_root); - vfsStream::newFile('settings.php')->at($sites_directory)->setContent(<<<'EOD' -<?php -$settings['config_sync_directory'] = 'foo'; -$config_directories['sync'] = 'bar'; -$config_directories['custom'] = 'custom'; -EOD - ); - - Settings::initialize(vfsStream::url('root'), 'sites', $class_loader); - $this->assertSame('foo', Settings::get('config_sync_directory')); - $this->assertSame('foo', $config_directories['sync']); - $this->assertSame('custom', $config_directories['custom']); - } - } -- GitLab