Skip to content

Commit 5c3cd23

Browse files
author
catch
committed
Issue #3097173 by alexpott, Berdir: Complete removal of $config_directories
1 parent 968a928 commit 5c3cd23

File tree

12 files changed

+11
-163
lines changed

12 files changed

+11
-163
lines changed

globals.api.php

-10
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@
5959
*/
6060
global $config;
6161

62-
/**
63-
* The location of file system directories used for site configuration data.
64-
*
65-
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
66-
* \Drupal\Core\Site\Settings::get('config_sync_directory') instead.
67-
*
68-
* @see https://www.drupal.org/node/3018145
69-
*/
70-
global $config_directories;
71-
7262
/**
7363
* Store settings and profile information during installation process.
7464
*

includes/install.core.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ function install_begin_request($class_loader, &$install_state) {
385385
}
386386
$install_state['database_verified'] = install_verify_database_settings($site_path);
387387
// A valid settings.php has database settings and a hash_salt value. Other
388-
// settings like config_directories will be checked by system_requirements().
388+
// settings will be checked by system_requirements().
389389
$install_state['settings_verified'] = $install_state['database_verified'] && (bool) Settings::get('hash_salt', FALSE);
390390

391391
// Install factory tables only after checking the database.

lib/Drupal/Core/DrupalKernel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ protected function getHttpKernel() {
13901390
protected function getConfigStorage() {
13911391
if (!isset($this->configStorage)) {
13921392
// The active configuration storage may not exist yet; e.g., in the early
1393-
// installer. Catch the exception thrown by config_get_config_directory().
1393+
// installer so if an exception is thrown use a NullStorage.
13941394
try {
13951395
$this->configStorage = BootstrapConfigStorageFactory::get($this->classLoader);
13961396
}

lib/Drupal/Core/Site/Settings.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static function getAll() {
116116
*/
117117
public static function initialize($app_root, $site_path, &$class_loader) {
118118
// Export these settings.php variables to the global namespace.
119-
global $config_directories, $config;
119+
global $config;
120120
$settings = [];
121121
$config = [];
122122
$databases = [];
@@ -128,16 +128,6 @@ public static function initialize($app_root, $site_path, &$class_loader) {
128128
// Initialize Database.
129129
Database::setMultipleConnectionInfo($databases);
130130

131-
// For BC ensure the $config_directories global is set both in the global
132-
// and settings.
133-
if (!isset($settings['config_sync_directory']) && !empty($config_directories['sync'])) {
134-
@trigger_error('$config_directories[\'sync\'] has moved to $settings[\'config_sync_directory\']. See https://www.drupal.org/node/3018145.', E_USER_DEPRECATED);
135-
$settings['config_sync_directory'] = $config_directories['sync'];
136-
}
137-
elseif (isset($settings['config_sync_directory'])) {
138-
$config_directories['sync'] = $settings['config_sync_directory'];
139-
}
140-
141131
// Initialize Settings.
142132
new Settings($settings);
143133
}

lib/Drupal/Core/Test/FunctionalTestSetupTrait.php

-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,6 @@ protected function prepareEnvironment() {
653653
$this->container = NULL;
654654

655655
// Unset globals.
656-
unset($GLOBALS['config_directories']);
657656
unset($GLOBALS['config']);
658657
unset($GLOBALS['conf']);
659658

modules/simpletest/src/TestBase.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,6 @@ private function prepareEnvironment() {
11631163
\Drupal::unsetContainer();
11641164

11651165
// Unset globals.
1166-
unset($GLOBALS['config_directories']);
11671166
unset($GLOBALS['config']);
11681167
unset($GLOBALS['conf']);
11691168

@@ -1276,8 +1275,8 @@ private function restoreEnvironment() {
12761275

12771276
// Re-initialize original stream wrappers of the parent site.
12781277
// This must happen after static variables have been reset and the original
1279-
// container and $config_directories are restored, as simpletest_log_read()
1280-
// uses the public stream wrapper to locate the error.log.
1278+
// container and settings are restored, as simpletest_log_read() uses the
1279+
// public stream wrapper to locate the error.log.
12811280
$this->originalContainer->get('stream_wrapper_manager')->register();
12821281

12831282
if (isset($this->originalPrefix)) {

modules/system/system.install

-26
Original file line numberDiff line numberDiff line change
@@ -696,32 +696,6 @@ function system_requirements($phase) {
696696
];
697697
}
698698

699-
// Handle other configuration directories. This will be removed in Drupal 9.
700-
// See https://www.drupal.org/node/3018145.
701-
$bc_config_directories = isset($GLOBALS['config_directories']) ? $GLOBALS['config_directories'] : [];
702-
unset($bc_config_directories['sync']);
703-
foreach (array_keys(array_filter($bc_config_directories)) as $type) {
704-
@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);
705-
$directory = config_get_config_directory($type);
706-
// If we're installing Drupal try and create the config sync directory.
707-
if (!is_dir($directory) && $phase == 'install') {
708-
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
709-
}
710-
if (!is_dir($directory)) {
711-
if ($phase == 'install') {
712-
$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']);
713-
}
714-
else {
715-
$description = t('The directory %directory does not exist.', ['%directory' => $directory]);
716-
}
717-
$requirements['config directory ' . $type] = [
718-
'title' => t('Configuration directory: %type', ['%type' => $type]),
719-
'description' => $description,
720-
'severity' => REQUIREMENT_ERROR,
721-
];
722-
}
723-
}
724-
725699
$requirements['file system'] = [
726700
'title' => t('File system'),
727701
];

modules/system/tests/src/Functional/System/StatusTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testStatusPage() {
6363
// If a module is fully installed no pending updates exists.
6464
$this->assertNoText(t('Out of date'));
6565

66-
// The global $config_directories is not properly formed.
66+
// The setting config_sync_directory is not properly formed.
6767
$this->assertRaw(t("Your %file file must define the %setting setting", ['%file' => $this->siteDirectory . '/settings.php', '%setting' => "\$settings['config_sync_directory']"]));
6868

6969
// Set the schema version of update_test_postupdate to a lower version, so

tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Drupal\Component\Utility\Crypt;
66

77
/**
8-
* Tests the installer when a config_directory set up but does not exist.
8+
* Tests installation when a config_sync_directory is set up but does not exist.
99
*
1010
* @group Installer
1111
*/

tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Drupal\FunctionalTests\Installer;
44

55
/**
6-
* Tests the installer when a config_directory has already been set up.
6+
* Tests installation when a config_sync_directory is exists and is set up.
77
*
88
* @group Installer
99
*/

tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ class DrupalKernelTest extends KernelTestBase {
1717
* {@inheritdoc}
1818
*/
1919
protected function setUp() {
20-
// DrupalKernel relies on global $config_directories and requires those
21-
// directories to exist. Therefore, create the directories, but do not
22-
// invoke KernelTestBase::setUp(), since that would set up further
23-
// environment aspects, which would distort this test, because it tests
24-
// the DrupalKernel (re-)building itself.
20+
// Do not invoke KernelTestBase::setUp(), since that would set up further
21+
// environment aspects, which would distort this test, because it tests the
22+
// DrupalKernel (re-)building itself.
2523
$this->root = static::getDrupalRoot();
2624
$this->bootEnvironment();
2725
}

tests/Drupal/Tests/Core/Site/SettingsTest.php

-102
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Drupal\Core\Site\Settings;
66
use Drupal\Tests\Traits\ExpectDeprecationTrait;
77
use Drupal\Tests\UnitTestCase;
8-
use org\bovigo\vfs\vfsStream;
98

109
/**
1110
* @coversDefaultClass \Drupal\Core\Site\Settings
@@ -151,105 +150,4 @@ public function testGetInstanceReflection() {
151150
$settings->getInstance();
152151
}
153152

154-
/**
155-
* @runInSeparateProcess
156-
* @group legacy
157-
* @covers ::__construct
158-
* @dataProvider configDirectoriesBcLayerProvider
159-
*/
160-
public function testConfigDirectoriesBcLayer($settings_file_content, $directory, $expect_deprecation) {
161-
global $config_directories;
162-
$class_loader = NULL;
163-
164-
$vfs_root = vfsStream::setup('root');
165-
$sites_directory = vfsStream::newDirectory('sites')->at($vfs_root);
166-
vfsStream::newFile('settings.php')
167-
->at($sites_directory)
168-
->setContent($settings_file_content);
169-
170-
if ($expect_deprecation) {
171-
$this->expectDeprecation('$config_directories[\'sync\'] has moved to $settings[\'config_sync_directory\']. See https://www.drupal.org/node/3018145.');
172-
}
173-
174-
Settings::initialize(vfsStream::url('root'), 'sites', $class_loader);
175-
$this->assertSame($directory, Settings::get('config_sync_directory'));
176-
$this->assertSame($directory, $config_directories['sync']);
177-
}
178-
179-
/**
180-
* Data provider for self::testConfigDirectoriesBcLayer().
181-
*/
182-
public function configDirectoriesBcLayerProvider() {
183-
$no_config_directories = <<<'EOD'
184-
<?php
185-
$settings['config_sync_directory'] = 'foo';
186-
EOD;
187-
188-
$only_config_directories = <<<'EOD'
189-
<?php
190-
$config_directories['sync'] = 'bar';
191-
EOD;
192-
193-
$both = <<<'EOD'
194-
<?php
195-
$settings['config_sync_directory'] = 'foo';
196-
$config_directories['sync'] = 'bar';
197-
EOD;
198-
199-
return [
200-
'Only $settings[\'config_sync_directory\']' => [
201-
$no_config_directories,
202-
'foo',
203-
FALSE,
204-
],
205-
'Only $config_directories' => [$only_config_directories, 'bar', TRUE],
206-
'Both' => [$both, 'foo', FALSE],
207-
];
208-
}
209-
210-
/**
211-
* @runInSeparateProcess
212-
* @group legacy
213-
*/
214-
public function testConfigDirectoriesBcLayerEmpty() {
215-
global $config_directories;
216-
$class_loader = NULL;
217-
218-
$vfs_root = vfsStream::setup('root');
219-
$sites_directory = vfsStream::newDirectory('sites')->at($vfs_root);
220-
vfsStream::newFile('settings.php')->at($sites_directory)->setContent(<<<'EOD'
221-
<?php
222-
$settings = [];
223-
EOD
224-
);
225-
226-
Settings::initialize(vfsStream::url('root'), 'sites', $class_loader);
227-
$this->assertNull(Settings::get('config_sync_directory'));
228-
$this->assertNull($config_directories);
229-
}
230-
231-
/**
232-
* @runInSeparateProcess
233-
* @group legacy
234-
*/
235-
public function testConfigDirectoriesBcLayerMultiple() {
236-
global $config_directories;
237-
$class_loader = NULL;
238-
239-
$vfs_root = vfsStream::setup('root');
240-
$sites_directory = vfsStream::newDirectory('sites')->at($vfs_root);
241-
vfsStream::newFile('settings.php')->at($sites_directory)->setContent(<<<'EOD'
242-
<?php
243-
$settings['config_sync_directory'] = 'foo';
244-
$config_directories['sync'] = 'bar';
245-
$config_directories['custom'] = 'custom';
246-
EOD
247-
);
248-
249-
Settings::initialize(vfsStream::url('root'), 'sites', $class_loader);
250-
$this->assertSame('foo', Settings::get('config_sync_directory'));
251-
$this->assertSame('foo', $config_directories['sync']);
252-
$this->assertSame('custom', $config_directories['custom']);
253-
}
254-
255153
}

0 commit comments

Comments
 (0)