diff --git a/core/core.services.yml b/core/core.services.yml index 9139f90..3fd70c2 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -252,10 +252,12 @@ services: factory_class: Drupal\Core\Config\FileStorageFactory factory_method: getActive public: false - config.storage.staging: + config.storage.import: class: Drupal\Core\Config\FileStorage factory_class: Drupal\Core\Config\FileStorageFactory - factory_method: getStaging + factory_method: getImport + config.storage.staging: + alias: config.storage.import config.storage.snapshot: class: Drupal\Core\Config\DatabaseStorage arguments: ['@database', config_snapshot] diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index e8808c2..87750f1 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -106,10 +106,20 @@ * $config_directories key for staging directory. * * @see config_get_config_directory() + * + * @deprecated in Drupal 8.0.0. Use CONFIG_IMPORT_DIRECTORY instead. Will be + * removed in Drupal 9.0.x */ const CONFIG_STAGING_DIRECTORY = 'staging'; /** + * $config_directories key for import directory. + * + * @see config_get_config_directory() + */ +const CONFIG_IMPORT_DIRECTORY = 'import'; + +/** * Defines the root directory of the Drupal installation. * * This strips two levels of directories off the current directory. @@ -162,7 +172,7 @@ function conf_path($require_settings = TRUE, $reset = FALSE, Request $request = * * @param string $type * (optional) The type of config directory to return. Drupal core provides - * 'active' and 'staging'. Defaults to CONFIG_ACTIVE_DIRECTORY. + * 'import'. Defaults to CONFIG_ACTIVE_DIRECTORY. * * @return string * The configuration directory path. @@ -173,6 +183,12 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) { if (!empty($config_directories[$type])) { return $config_directories[$type]; } + if ($type == CONFIG_IMPORT_DIRECTORY && isset($config_directories[CONFIG_STAGING_DIRECTORY])) { + return $config_directories[CONFIG_STAGING_DIRECTORY]; + } + if ($type == CONFIG_STAGING_DIRECTORY && isset($config_directories[CONFIG_IMPORT_DIRECTORY])) { + return $config_directories[CONFIG_IMPORT_DIRECTORY]; + } throw new \Exception(format_string('The configuration directory type %type does not exist.', array('%type' => $type))); } diff --git a/core/includes/file.inc b/core/includes/file.inc index 60cec1c..6de71d9 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -428,7 +428,7 @@ function file_ensure_htaccess() { } file_save_htaccess('temporary://', TRUE); file_save_htaccess(config_get_config_directory(), TRUE); - file_save_htaccess(config_get_config_directory(CONFIG_STAGING_DIRECTORY), TRUE); + file_save_htaccess(config_get_config_directory(CONFIG_IMPORT_DIRECTORY), TRUE); } /** diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 554ad06..3a09957 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -366,7 +366,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_ACTIVE_DIRECTORY) && install_ensure_config_directory(CONFIG_IMPORT_DIRECTORY); $install_state['database_verified'] = install_verify_database_settings(); $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 be380ae..7447119 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -183,8 +183,8 @@ function drupal_get_database_types() { * 'value' => 'config_hash/active' * 'required' => TRUE, * ), - * CONFIG_STAGING_DIRECTORY => (object) array( - * 'value' => 'config_hash/staging', + * CONFIG_IMPORT_DIRECTORY => (object) array( + * 'value' => 'config_hash/import', * 'required' => TRUE, * ), * ); @@ -192,7 +192,7 @@ function drupal_get_database_types() { * gets dumped as: * @code * $config_directories['active'] = 'config_hash/active'; - * $config_directories['staging'] = 'config_hash/staging' + * $config_directories['import'] = 'config_hash/import' * @endcode */ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { @@ -474,9 +474,9 @@ function drupal_install_config_directories() { 'required' => TRUE, ]; } - if (empty($config_directories[CONFIG_STAGING_DIRECTORY])) { - $settings['config_directories'][CONFIG_STAGING_DIRECTORY] = (object) [ - 'value' => conf_path() . '/files/config_' . $config_directories_hash . '/staging', + if (empty($config_directories[CONFIG_IMPORT_DIRECTORY])) { + $settings['config_directories'][CONFIG_IMPORT_DIRECTORY] = (object) [ + 'value' => conf_path() . '/files/config_' . $config_directories_hash . '/import', 'required' => TRUE, ]; } @@ -487,7 +487,7 @@ function drupal_install_config_directories() { } // Ensure the config directories exist or can be created, and are writable. - foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $config_type) { + foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_IMPORT_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 @@ -509,7 +509,7 @@ function drupal_install_config_directories() { 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: + case CONFIG_IMPORT_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; } diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index 4f28425..3fa1a67 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -363,8 +363,8 @@ protected function createExtensionChangelist() { $current_extensions = $this->storageComparer->getTargetStorage()->read('core.extension'); $new_extensions = $this->storageComparer->getSourceStorage()->read('core.extension'); - // If there is no extension information in staging then exit. This is - // probably due to an empty staging directory. + // If there is no extension information in import then exit. This is + // probably due to an empty import directory. if (!$new_extensions) { return; } @@ -755,7 +755,7 @@ protected function processConfiguration($collection, $op, $name) { * The name of the extension to process. */ protected function processExtension($type, $op, $name) { - // Set the config installer to use the staging directory instead of the + // Set the config installer to use the import directory instead of the // extensions own default config directories. \Drupal::service('config.installer') ->setSyncing(TRUE) diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php index a762de9..ff2171d 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php @@ -85,7 +85,7 @@ * configuration object so that they can be checked without the module that * provides the configuration entity class being installed. This is important * for configuration synchronization, which needs to be able to validate - * configuration in the staging directory before the synchronization has + * configuration in the import directory before the synchronization has * occurred. Also, if you have a configuration entity object and you want to * get the current dependencies without recalculation, you can use * \Drupal\Core\Config\Entity\ConfigEntityInterface::getDependencies(). diff --git a/core/lib/Drupal/Core/Config/FileStorageFactory.php b/core/lib/Drupal/Core/Config/FileStorageFactory.php index 1768df4..798f46c 100644 --- a/core/lib/Drupal/Core/Config/FileStorageFactory.php +++ b/core/lib/Drupal/Core/Config/FileStorageFactory.php @@ -24,9 +24,21 @@ static function getActive() { * Returns a FileStorage object working with the staging config directory. * * @return \Drupal\Core\Config\FileStorage FileStorage + * + * @deprecated in Drupal 8.0.0. Will be removed in Drupal 9.0.x. The staging + * directory as been renamed import. */ static function getStaging() { - return new FileStorage(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); + static::getImport(); + } + + /** + * Returns a FileStorage object working with the import config directory. + * + * @return \Drupal\Core\Config\FileStorage FileStorage + */ + static function getImport() { + return new FileStorage(config_get_config_directory(CONFIG_IMPORT_DIRECTORY)); } } diff --git a/core/modules/config/config.module b/core/modules/config/config.module index 84e0210..5bb7103 100644 --- a/core/modules/config/config.module +++ b/core/modules/config/config.module @@ -22,7 +22,7 @@ function config_help($route_name, RouteMatchInterface $route_match) { case 'config.sync': $output = ''; - $output .= '

' . t('Import configuration that is placed in your staging directory. All changes, deletions, renames, and additions are listed below.') . '

'; + $output .= '

' . t('Import configuration that is placed in your import directory. All changes, deletions, renames, and additions are listed below.') . '

'; return $output; } } diff --git a/core/modules/config/src/Controller/ConfigController.php b/core/modules/config/src/Controller/ConfigController.php index dc56910..1f3eea3 100644 --- a/core/modules/config/src/Controller/ConfigController.php +++ b/core/modules/config/src/Controller/ConfigController.php @@ -64,7 +64,7 @@ class ConfigController implements ContainerInjectionInterface { public static function create(ContainerInterface $container) { return new static( $container->get('config.storage'), - $container->get('config.storage.staging'), + $container->get('config.storage.import'), $container->get('config.manager'), new FileDownloadController(), $container->get('diff.formatter') diff --git a/core/modules/config/src/Form/ConfigImportForm.php b/core/modules/config/src/Form/ConfigImportForm.php index 9ed9b83..194eb71 100644 --- a/core/modules/config/src/Form/ConfigImportForm.php +++ b/core/modules/config/src/Form/ConfigImportForm.php @@ -40,7 +40,7 @@ public function __construct(StorageInterface $config_storage) { */ public static function create(ContainerInterface $container) { return new static( - $container->get('config.storage.staging') + $container->get('config.storage.import') ); } @@ -96,7 +96,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($archiver->listContent() as $file) { $files[] = $file['filename']; } - $archiver->extractList($files, config_get_config_directory(CONFIG_STAGING_DIRECTORY)); + $archiver->extractList($files, config_get_config_directory(CONFIG_IMPORT_DIRECTORY)); drupal_set_message($this->t('Your configuration files were successfully uploaded, ready for import.')); $form_state->setRedirect('config.sync'); } diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index b97218b..d7f7082 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -38,11 +38,11 @@ class ConfigSync extends FormBase { protected $lock; /** - * The staging configuration object. + * The import configuration storage. * * @var \Drupal\Core\Config\StorageInterface */ - protected $stagingStorage; + protected $importStorage; /** * The active configuration object. @@ -103,7 +103,7 @@ class ConfigSync extends FormBase { /** * Constructs the object. * - * @param \Drupal\Core\Config\StorageInterface $staging_storage + * @param \Drupal\Core\Config\StorageInterface $import_storage * The source storage. * @param \Drupal\Core\Config\StorageInterface $active_storage * The target storage. @@ -124,8 +124,8 @@ class ConfigSync extends FormBase { * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler */ - public function __construct(StorageInterface $staging_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler) { - $this->stagingStorage = $staging_storage; + public function __construct(StorageInterface $import_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler) { + $this->importStorage = $import_storage; $this->activeStorage = $active_storage; $this->snapshotStorage = $snapshot_storage; $this->lock = $lock; @@ -142,7 +142,7 @@ public function __construct(StorageInterface $staging_storage, StorageInterface */ public static function create(ContainerInterface $container) { return new static( - $container->get('config.storage.staging'), + $container->get('config.storage.import'), $container->get('config.storage'), $container->get('config.storage.snapshot'), $container->get('lock.persistent'), @@ -194,8 +194,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Import all'), ); - $source_list = $this->stagingStorage->listAll(); - $storage_comparer = new StorageComparer($this->stagingStorage, $this->activeStorage, $this->configManager); + $source_list = $this->importStorage->listAll(); + $storage_comparer = new StorageComparer($this->importStorage, $this->activeStorage, $this->configManager); if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) { $form['no_changes'] = array( '#type' => 'table', diff --git a/core/modules/config/src/Tests/ConfigStagingBcTest.php b/core/modules/config/src/Tests/ConfigStagingBcTest.php new file mode 100644 index 0000000..4efb937 --- /dev/null +++ b/core/modules/config/src/Tests/ConfigStagingBcTest.php @@ -0,0 +1,43 @@ +assertEqual($this->configDirectories[CONFIG_IMPORT_DIRECTORY], config_get_config_directory(CONFIG_STAGING_DIRECTORY), 'The import config directory can be accessed with CONFIG_STAGING_DIRECTORY if no staging key exists.'); + + // Reset the global variable. + $config_directories = []; + // Pre-configure config directories. + $settings['config_directories'] = array( + CONFIG_STAGING_DIRECTORY => (object) array( + 'value' => $this->publicFilesDirectory . '/config_staging', + 'required' => TRUE, + ), + ); + $this->writeSettings($settings); + $this->assertEqual($this->publicFilesDirectory . '/config_staging', config_get_config_directory(CONFIG_IMPORT_DIRECTORY), 'The import config directory can be accessed with CONFIG_IMPORT_DIRECTORY if only staging key exists.'); + + } + +} diff --git a/core/modules/field/src/Tests/FieldImportCreateTest.php b/core/modules/field/src/Tests/FieldImportCreateTest.php index 0d46566..4a334bf 100644 --- a/core/modules/field/src/Tests/FieldImportCreateTest.php +++ b/core/modules/field/src/Tests/FieldImportCreateTest.php @@ -98,7 +98,7 @@ function testImportCreate() { // Add the new files to the staging directory. $src_dir = drupal_get_path('module', 'field_test_config') . '/staging'; - $target_dir = $this->configDirectories[CONFIG_STAGING_DIRECTORY]; + $target_dir = $this->configDirectories[CONFIG_IMPORT_DIRECTORY]; $this->assertTrue(file_unmanaged_copy("$src_dir/$field_storage_config_name.yml", "$target_dir/$field_storage_config_name.yml")); $this->assertTrue(file_unmanaged_copy("$src_dir/$field_config_name.yml", "$target_dir/$field_config_name.yml")); $this->assertTrue(file_unmanaged_copy("$src_dir/$field_storage_config_name_2.yml", "$target_dir/$field_storage_config_name_2.yml")); diff --git a/core/modules/node/src/Tests/Config/NodeImportCreateTest.php b/core/modules/node/src/Tests/Config/NodeImportCreateTest.php index 97fe51f..eb4bc09 100644 --- a/core/modules/node/src/Tests/Config/NodeImportCreateTest.php +++ b/core/modules/node/src/Tests/Config/NodeImportCreateTest.php @@ -65,7 +65,7 @@ public function testImportCreate() { $this->copyConfig($active, $staging); // Manually add new node type. $src_dir = drupal_get_path('module', 'node_test_config') . '/staging'; - $target_dir = $this->configDirectories[CONFIG_STAGING_DIRECTORY]; + $target_dir = $this->configDirectories[CONFIG_IMPORT_DIRECTORY]; $this->assertTrue(file_unmanaged_copy("$src_dir/$node_type_config_name.yml", "$target_dir/$node_type_config_name.yml")); // Import the content of the staging directory. diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php index 5abf972..f6cb600 100644 --- a/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -112,13 +112,13 @@ protected function beforePrepareEnvironment() { * @see config_get_config_directory() * * @throws \RuntimeException - * Thrown when CONFIG_ACTIVE_DIRECTORY or CONFIG_STAGING_DIRECTORY cannot + * Thrown when CONFIG_ACTIVE_DIRECTORY or CONFIG_IMPORT_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) { + foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_IMPORT_DIRECTORY) as $type) { // Assign the relative path to the global variable. $path = $this->siteDirectory . '/config_' . $type; $GLOBALS['config_directories'][$type] = $path; diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index 9a38774..14b0c8b 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -1604,7 +1604,7 @@ public function configImporter() { if (!$this->configImporter) { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( - $this->container->get('config.storage.staging'), + $this->container->get('config.storage.import'), $this->container->get('config.storage'), $this->container->get('config.manager') ); diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 14c894a..f9b4b0e 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -110,7 +110,7 @@ * and HAL. * - Node entity support is configured by default. If you would like to support * other types of entities, you can copy - * core/modules/rest/config/install/rest.settings.yml to your staging + * core/modules/rest/config/install/rest.settings.yml to your import * configuration directory, appropriately modified for other entity types, * and import it. Support for GET on the log from the Database Logging module * can also be enabled in this way; in this case, the 'entity:node' line diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php index 61dd5be..79a20f8 100644 --- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php @@ -48,13 +48,13 @@ protected function setUp() { 'value' => conf_path() . '/files/config_active', 'required' => TRUE, ), - CONFIG_STAGING_DIRECTORY => (object) array( - 'value' => conf_path() . '/files/config_staging', + CONFIG_IMPORT_DIRECTORY => (object) array( + 'value' => conf_path() . '/files/config_import', 'required' => TRUE, ), ); mkdir($this->settings['config_directories'][CONFIG_ACTIVE_DIRECTORY]->value, 0777, TRUE); - mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE); + mkdir($this->settings['config_directories'][CONFIG_IMPORT_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 25be1ef..89b6dab 100644 --- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php @@ -54,13 +54,13 @@ protected function setUp() { 'value' => conf_path() . '/files/config_active', 'required' => TRUE, ), - CONFIG_STAGING_DIRECTORY => (object) array( - 'value' => conf_path() . '/files/config_staging', + CONFIG_IMPORT_DIRECTORY => (object) array( + 'value' => conf_path() . '/files/config_import', 'required' => TRUE, ), ); mkdir($this->settings['config_directories'][CONFIG_ACTIVE_DIRECTORY]->value, 0777, TRUE); - mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE); + mkdir($this->settings['config_directories'][CONFIG_IMPORT_DIRECTORY]->value, 0777, TRUE); parent::setUp(); }