Issue #3097173 by alexpott, Berdir: Complete removal of $config_directories

merge-requests/2419/head
catch 2019-11-28 12:14:11 +00:00
parent dc7f83de6c
commit d79a645b27
12 changed files with 11 additions and 163 deletions

View File

@ -59,16 +59,6 @@ global $conf;
*/
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.
*

View File

@ -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.

View File

@ -1390,7 +1390,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
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);
}

View File

@ -116,7 +116,7 @@ final class Settings {
*/
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 @@ final class Settings {
// 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);
}

View File

@ -653,7 +653,6 @@ trait FunctionalTestSetupTrait {
$this->container = NULL;
// Unset globals.
unset($GLOBALS['config_directories']);
unset($GLOBALS['config']);
unset($GLOBALS['conf']);

View File

@ -1163,7 +1163,6 @@ abstract class TestBase {
\Drupal::unsetContainer();
// Unset globals.
unset($GLOBALS['config_directories']);
unset($GLOBALS['config']);
unset($GLOBALS['conf']);
@ -1276,8 +1275,8 @@ abstract class TestBase {
// 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)) {

View File

@ -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'),
];

View File

@ -63,7 +63,7 @@ class StatusTest extends BrowserTestBase {
// 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

View File

@ -5,7 +5,7 @@ namespace Drupal\FunctionalTests\Installer;
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
*/

View File

@ -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
*/

View File

@ -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();
}

View File

@ -5,7 +5,6 @@ namespace Drupal\Tests\Core\Site;
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 @@ class SettingsTest extends UnitTestCase {
$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']);
}
}