summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2015-09-09 12:06:17 (GMT)
committerNathaniel Catchpole2015-09-09 12:06:17 (GMT)
commit02569d158f239e58d2f436f91a850bf55d2e12e8 (patch)
tree025b0ae21b2817755a9508ad2b6e56d533456289
parent795d9f9221e9ebdc52d3206dcf055d5416342b4e (diff)
Issue #2487592 by alexpott, JeroenT, Schnitzel, cilefen: CMI: don't ship with a default "active" directory that is empty in most Drupal installations
-rw-r--r--core/core.services.yml4
-rw-r--r--core/includes/bootstrap.inc14
-rw-r--r--core/includes/file.inc1
-rw-r--r--core/includes/install.core.inc2
-rw-r--r--core/includes/install.inc57
-rw-r--r--core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php8
-rw-r--r--core/lib/Drupal/Core/Config/FileStorageFactory.php3
-rw-r--r--core/modules/config/src/Tests/ConfigFileContentTest.php2
-rw-r--r--core/modules/config/src/Tests/ConfigImporterTest.php17
-rw-r--r--core/modules/config/src/Tests/Storage/CachedStorageTest.php5
-rw-r--r--core/modules/config/src/Tests/Storage/FileStorageTest.php16
-rw-r--r--core/modules/simpletest/src/KernelTestBase.php21
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php9
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php5
-rw-r--r--core/tests/Drupal/KernelTests/KernelTestBase.php3
-rw-r--r--core/tests/Drupal/KernelTests/KernelTestBaseTest.php1
-rw-r--r--sites/default/default.settings.php1
17 files changed, 88 insertions, 81 deletions
diff --git a/core/core.services.yml b/core/core.services.yml
index 090d8f3..c476e68 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -290,10 +290,6 @@ services:
public: false
tags:
- { name: backend_overridable }
- config.storage.file:
- class: Drupal\Core\Config\FileStorage
- factory: Drupal\Core\Config\FileStorageFactory::getActive
- public: false
config.storage.staging:
class: Drupal\Core\Config\FileStorage
factory: Drupal\Core\Config\FileStorageFactory::getStaging
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 20b124b..b24430c 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -101,6 +101,9 @@ const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
* $config_directories key for active directory.
*
* @see config_get_config_directory()
+ *
+ * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Drupal core no
+ * longer creates an active directory.
*/
const CONFIG_ACTIVE_DIRECTORY = 'active';
@@ -162,14 +165,19 @@ function conf_path($require_settings = TRUE, $reset = FALSE, Request $request =
/**
* Returns the path of a configuration directory.
*
+ * Configuration directories are configured using $config_directories in
+ * settings.php.
+ *
* @param string $type
- * (optional) The type of config directory to return. Drupal core provides
- * 'active' and 'staging'. Defaults to CONFIG_ACTIVE_DIRECTORY.
+ * The type of config directory to return. Drupal core provides the
+ * CONFIG_STAGING_DIRECTORY constant to access the staging directory.
*
* @return string
* The configuration directory path.
+ *
+ * @throws \Exception
*/
-function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
+function config_get_config_directory($type) {
global $config_directories;
if (!empty($config_directories[$type])) {
diff --git a/core/includes/file.inc b/core/includes/file.inc
index c5027c0..316c54f 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -335,7 +335,6 @@ function file_ensure_htaccess() {
file_save_htaccess('private://', TRUE);
}
file_save_htaccess('temporary://', TRUE);
- file_save_htaccess(config_get_config_directory(), TRUE);
file_save_htaccess(config_get_config_directory(CONFIG_STAGING_DIRECTORY), TRUE);
}
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 36612ecf..ad39590 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -365,7 +365,7 @@ function install_begin_request($class_loader, &$install_state) {
\Drupal::setContainer($container);
// Determine whether base system services are ready to operate.
- $install_state['config_verified'] = install_ensure_config_directory(CONFIG_ACTIVE_DIRECTORY) && install_ensure_config_directory(CONFIG_STAGING_DIRECTORY);
+ $install_state['config_verified'] = install_ensure_config_directory(CONFIG_STAGING_DIRECTORY);
$install_state['database_verified'] = install_verify_database_settings($site_path);
$install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified'];
diff --git a/core/includes/install.inc b/core/includes/install.inc
index c885553..42b0d40 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -178,10 +178,6 @@ function drupal_get_database_types() {
* and comment properties.
* @code
* $settings['config_directories'] = array(
- * CONFIG_ACTIVE_DIRECTORY => (object) array(
- * 'value' => 'config_hash/active'
- * 'required' => TRUE,
- * ),
* CONFIG_STAGING_DIRECTORY => (object) array(
* 'value' => 'config_hash/staging',
* 'required' => TRUE,
@@ -467,12 +463,6 @@ function drupal_install_config_directories() {
// manually defined in the existing already.
$settings = [];
$config_directories_hash = Crypt::randomBytesBase64(55);
- if (empty($config_directories[CONFIG_ACTIVE_DIRECTORY])) {
- $settings['config_directories'][CONFIG_ACTIVE_DIRECTORY] = (object) [
- 'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/active',
- 'required' => TRUE,
- ];
- }
if (empty($config_directories[CONFIG_STAGING_DIRECTORY])) {
$settings['config_directories'][CONFIG_STAGING_DIRECTORY] = (object) [
'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/staging',
@@ -485,36 +475,25 @@ function drupal_install_config_directories() {
drupal_rewrite_settings($settings);
}
- // Ensure the config directories exist or can be created, and are writable.
- foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $config_type) {
- // This should never fail, since if the config directory was specified in
- // settings.php it will have already been created and verified earlier, and
- // if it wasn't specified in settings.php, it is created here inside the
- // public files directory, which has already been verified to be writable
- // itself. But if it somehow fails anyway, the installation cannot proceed.
- // Bail out using a similar error message as in system_requirements().
- if (!install_ensure_config_directory($config_type)) {
- throw new Exception(t('The directory %directory could not be created or could not be made writable. 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 the <a href="@handbook_url">online handbook</a>.', array(
- '%directory' => config_get_config_directory($config_type),
- '@handbook_url' => 'https://www.drupal.org/server-permissions',
- )));
- }
-
- // Put a README.txt into each config directory. This is required so that
- // they can later be added to git. Since these directories are auto-
- // created, we have to write out the README rather than just adding it
- // to the drupal core repo.
- switch ($config_type) {
- case CONFIG_ACTIVE_DIRECTORY:
- $text = 'If you change the configuration system to use file storage instead of the database for the active Drupal site configuration, this directory will contain the active configuration. By default, this directory will be empty. If you are using files to store the active configuration, and you want to move it between environments, files from this directory should be placed in the staging directory on the target server. To make this configuration active, visit admin/config/development/configuration/sync on the target server.';
- break;
- case CONFIG_STAGING_DIRECTORY:
- $text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.';
- break;
- }
- $text .= ' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
- file_put_contents(config_get_config_directory($config_type) . '/README.txt', $text);
+ // This should never fail, since if the config directory was specified in
+ // settings.php it will have already been created and verified earlier, and
+ // if it wasn't specified in settings.php, it is created here inside the
+ // public files directory, which has already been verified to be writable
+ // itself. But if it somehow fails anyway, the installation cannot proceed.
+ // Bail out using a similar error message as in system_requirements().
+ if (!install_ensure_config_directory(CONFIG_STAGING_DIRECTORY)) {
+ throw new Exception(t('The directory %directory could not be created or could not be made writable. 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 the <a href="@handbook_url">online handbook</a>.', array(
+ '%directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY),
+ '@handbook_url' => 'https://www.drupal.org/server-permissions',
+ )));
}
+
+ // Put a README.txt into the staging config directory. This is required so
+ // that they can later be added to git. Since this directory is auto-
+ // created, we have to write out the README rather than just adding it
+ // to the drupal core repo.
+ $text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.' .' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
+ file_put_contents(config_get_config_directory(CONFIG_STAGING_DIRECTORY) . '/README.txt', $text);
}
/**
diff --git a/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php b/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php
index afc8012..a0988e2 100644
--- a/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php
+++ b/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php
@@ -48,7 +48,15 @@ class BootstrapConfigStorageFactory {
/**
* Returns a File-based configuration storage implementation.
*
+ * If there is no active configuration directory calling this method will
+ * result in an error.
+ *
* @return \Drupal\Core\Config\FileStorage
+ *
+ * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Drupal core
+ * no longer creates an active directory.
+ *
+ * @throws \Exception
*/
public static function getFileStorage() {
return new FileStorage(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY));
diff --git a/core/lib/Drupal/Core/Config/FileStorageFactory.php b/core/lib/Drupal/Core/Config/FileStorageFactory.php
index 3da4ecf..49ccbd9 100644
--- a/core/lib/Drupal/Core/Config/FileStorageFactory.php
+++ b/core/lib/Drupal/Core/Config/FileStorageFactory.php
@@ -16,6 +16,9 @@ class FileStorageFactory {
* Returns a FileStorage object working with the active config directory.
*
* @return \Drupal\Core\Config\FileStorage FileStorage
+ *
+ * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Drupal core
+ * no longer creates an active directory.
*/
static function getActive() {
return new FileStorage(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY));
diff --git a/core/modules/config/src/Tests/ConfigFileContentTest.php b/core/modules/config/src/Tests/ConfigFileContentTest.php
index 8818f41..2f7c5db 100644
--- a/core/modules/config/src/Tests/ConfigFileContentTest.php
+++ b/core/modules/config/src/Tests/ConfigFileContentTest.php
@@ -210,7 +210,7 @@ class ConfigFileContentTest extends KernelTestBase {
);
// Encode and write, and reload and decode the configuration data.
- $filestorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]);
+ $filestorage = new FileStorage($this->configDirectories[CONFIG_STAGING_DIRECTORY]);
$filestorage->write($name, $config_data);
$config_parsed = $filestorage->read($name);
diff --git a/core/modules/config/src/Tests/ConfigImporterTest.php b/core/modules/config/src/Tests/ConfigImporterTest.php
index e39baf6..ef90685 100644
--- a/core/modules/config/src/Tests/ConfigImporterTest.php
+++ b/core/modules/config/src/Tests/ConfigImporterTest.php
@@ -673,4 +673,21 @@ class ConfigImporterTest extends KernelTestBase {
}
}
+ /**
+ * Tests config_get_config_directory().
+ */
+ public function testConfigGetConfigDirectory() {
+ $directory = config_get_config_directory(CONFIG_STAGING_DIRECTORY);
+ $this->assertEqual($this->configDirectories[CONFIG_STAGING_DIRECTORY], $directory);
+
+ $message = 'Calling config_get_config_directory() with CONFIG_ACTIVE_DIRECTORY results in an exception.';
+ try {
+ config_get_config_directory(CONFIG_ACTIVE_DIRECTORY);
+ $this->fail($message);
+ }
+ catch (\Exception $e) {
+ $this->pass($message);
+ }
+ }
+
}
diff --git a/core/modules/config/src/Tests/Storage/CachedStorageTest.php b/core/modules/config/src/Tests/Storage/CachedStorageTest.php
index 2dd99ad..4d8a8ac 100644
--- a/core/modules/config/src/Tests/Storage/CachedStorageTest.php
+++ b/core/modules/config/src/Tests/Storage/CachedStorageTest.php
@@ -36,7 +36,10 @@ class CachedStorageTest extends ConfigStorageTestBase {
protected function setUp() {
parent::setUp();
- $this->fileStorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]);
+ // Create a directory.
+ $dir = $this->publicFilesDirectory . '/config';
+ mkdir($dir);
+ $this->fileStorage = new FileStorage($dir);
$this->storage = new CachedStorage($this->fileStorage, \Drupal::service('cache.config'));
$this->cache = \Drupal::service('cache_factory')->get('config');
// ::listAll() verifications require other configuration data to exist.
diff --git a/core/modules/config/src/Tests/Storage/FileStorageTest.php b/core/modules/config/src/Tests/Storage/FileStorageTest.php
index 2407c67..932c54e 100644
--- a/core/modules/config/src/Tests/Storage/FileStorageTest.php
+++ b/core/modules/config/src/Tests/Storage/FileStorageTest.php
@@ -18,12 +18,22 @@ use Drupal\Core\Config\FileStorage;
class FileStorageTest extends ConfigStorageTestBase {
/**
+ * A directory to store configuration in.
+ *
+ * @var string
+ */
+ protected $directory;
+
+ /**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->storage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]);
- $this->invalidStorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY] . '/nonexisting');
+ // Create a directory.
+ $this->directory = $this->publicFilesDirectory . '/config';
+ mkdir($this->directory);
+ $this->storage = new FileStorage($this->directory);
+ $this->invalidStorage = new FileStorage($this->directory . '/nonexisting');
// FileStorage::listAll() requires other configuration data to exist.
$this->storage->write('system.performance', $this->config('system.performance')->get());
@@ -60,7 +70,7 @@ class FileStorageTest extends ConfigStorageTestBase {
$this->assertIdentical($config_files, $expected_files, 'Relative path, two config files found.');
// Initialize FileStorage with absolute file path.
- $absolute_path = realpath($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]);
+ $absolute_path = realpath($this->directory);
$storage_absolute_path = new FileStorage($absolute_path);
$config_files = $storage_absolute_path->listAll();
$this->assertIdentical($config_files, $expected_files, 'Absolute path, two config files found.');
diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php
index eaa545c..419f566 100644
--- a/core/modules/simpletest/src/KernelTestBase.php
+++ b/core/modules/simpletest/src/KernelTestBase.php
@@ -116,23 +116,20 @@ abstract class KernelTestBase extends TestBase {
* @see config_get_config_directory()
*
* @throws \RuntimeException
- * Thrown when CONFIG_ACTIVE_DIRECTORY or CONFIG_STAGING_DIRECTORY cannot
- * be created or made writable.
+ * Thrown when CONFIG_STAGING_DIRECTORY cannot be created or made writable.
*/
protected function prepareConfigDirectories() {
$this->configDirectories = array();
include_once DRUPAL_ROOT . '/core/includes/install.inc';
- foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $type) {
- // Assign the relative path to the global variable.
- $path = $this->siteDirectory . '/config_' . $type;
- $GLOBALS['config_directories'][$type] = $path;
- // Ensure the directory can be created and is writeable.
- if (!install_ensure_config_directory($type)) {
- throw new \RuntimeException("Failed to create '$type' config directory $path");
- }
- // Provide the already resolved path for tests.
- $this->configDirectories[$type] = $path;
+ // Assign the relative path to the global variable.
+ $path = $this->siteDirectory . '/config_' . CONFIG_STAGING_DIRECTORY;
+ $GLOBALS['config_directories'][CONFIG_STAGING_DIRECTORY] = $path;
+ // Ensure the directory can be created and is writeable.
+ if (!install_ensure_config_directory(CONFIG_STAGING_DIRECTORY)) {
+ throw new \RuntimeException("Failed to create '" . CONFIG_STAGING_DIRECTORY . "' config directory $path");
}
+ // Provide the already resolved path for tests.
+ $this->configDirectories[CONFIG_STAGING_DIRECTORY] = $path;
}
/**
diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php
index 61dd5be..1b915d5 100644
--- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php
@@ -7,9 +7,11 @@
namespace Drupal\system\Tests\Installer;
+use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Drupal\simpletest\InstallerTestBase;
use Drupal\Core\Database\Database;
+use Symfony\Component\HttpFoundation\Request;
/**
* Tests the installer with an existing settings file but no install profile.
@@ -44,16 +46,11 @@ class InstallerExistingSettingsNoProfileTest extends InstallerTestBase {
// Pre-configure config directories.
$this->settings['config_directories'] = array(
- CONFIG_ACTIVE_DIRECTORY => (object) array(
- 'value' => conf_path() . '/files/config_active',
- 'required' => TRUE,
- ),
CONFIG_STAGING_DIRECTORY => (object) array(
- 'value' => conf_path() . '/files/config_staging',
+ 'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_staging',
'required' => TRUE,
),
);
- mkdir($this->settings['config_directories'][CONFIG_ACTIVE_DIRECTORY]->value, 0777, TRUE);
mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE);
parent::setUp();
diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php
index 08ae978..0d906f8 100644
--- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php
@@ -55,16 +55,11 @@ class InstallerExistingSettingsTest extends InstallerTestBase {
$site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
// Pre-configure config directories.
$this->settings['config_directories'] = array(
- CONFIG_ACTIVE_DIRECTORY => (object) array(
- 'value' => $site_path . '/files/config_active',
- 'required' => TRUE,
- ),
CONFIG_STAGING_DIRECTORY => (object) array(
'value' => $site_path . '/files/config_staging',
'required' => TRUE,
),
);
- mkdir($this->settings['config_directories'][CONFIG_ACTIVE_DIRECTORY]->value, 0777, TRUE);
mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE);
parent::setUp();
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index a57a247..a09227b 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -254,7 +254,6 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
$this->siteDirectory = vfsStream::url('root/sites/simpletest/' . $suffix);
mkdir($this->siteDirectory . '/files', 0775);
- mkdir($this->siteDirectory . '/files/config/' . CONFIG_ACTIVE_DIRECTORY, 0775, TRUE);
mkdir($this->siteDirectory . '/files/config/' . CONFIG_STAGING_DIRECTORY, 0775, TRUE);
// Ensure that all code that relies on drupal_valid_test_ua() can still be
@@ -273,7 +272,6 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
new Settings($settings);
$GLOBALS['config_directories'] = array(
- CONFIG_ACTIVE_DIRECTORY => $this->siteDirectory . '/files/config/active',
CONFIG_STAGING_DIRECTORY => $this->siteDirectory . '/files/config/staging',
);
@@ -1049,7 +1047,6 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
if ($name === 'configDirectories') {
trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use config_get_config_directory() directly instead.", $name), E_USER_DEPRECATED);
return array(
- CONFIG_ACTIVE_DIRECTORY => config_get_config_directory(CONFIG_ACTIVE_DIRECTORY),
CONFIG_STAGING_DIRECTORY => config_get_config_directory(CONFIG_STAGING_DIRECTORY),
);
}
diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
index ece98b3..397b55e 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
@@ -38,7 +38,6 @@ class KernelTestBaseTest extends KernelTestBase {
substr($this->databasePrefix, 10) => array(
'files' => array(
'config' => array(
- 'active' => array(),
'staging' => array(),
),
),
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index f590613..fd90273 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -238,7 +238,6 @@ $databases = array();
* Example:
* @code
* $config_directories = array(
- * CONFIG_ACTIVE_DIRECTORY => '/some/directory/outside/webroot',
* CONFIG_STAGING_DIRECTORY => '/another/directory/outside/webroot',
* );
* @endcode