Commit bfb117c5 authored by xjm's avatar xjm

Issue #2487588 by YesCT, Leksat, Schnitzel, alexpott, anavarre, xjm: Move CMI...

Issue #2487588 by YesCT, Leksat, Schnitzel, alexpott, anavarre, xjm: Move CMI import/export directory "staging" to "sync", as it is confused with staging environments
parent 09990f57
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
* and HAL. * and HAL.
* - Node entity support is configured by default. If you would like to support * - Node entity support is configured by default. If you would like to support
* other types of entities, you can copy * 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 sync
* configuration directory, appropriately modified for other entity types, * configuration directory, appropriately modified for other entity types,
* and import it. Support for GET on the log from the Database Logging module * 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 * can also be enabled in this way; in this case, the 'entity:node' line
......
...@@ -290,9 +290,13 @@ services: ...@@ -290,9 +290,13 @@ services:
public: false public: false
tags: tags:
- { name: backend_overridable } - { name: backend_overridable }
# @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Use
# config.storage.sync instead.
config.storage.staging: config.storage.staging:
class: Drupal\Core\Config\FileStorage class: Drupal\Core\Config\FileStorage
factory: Drupal\Core\Config\FileStorageFactory::getStaging factory: Drupal\Core\Config\FileStorageFactory::getSync
config.storage.sync:
alias: config.storage.staging
config.storage.snapshot: config.storage.snapshot:
class: Drupal\Core\Config\DatabaseStorage class: Drupal\Core\Config\DatabaseStorage
arguments: ['@database', config_snapshot] arguments: ['@database', config_snapshot]
......
...@@ -108,10 +108,21 @@ ...@@ -108,10 +108,21 @@
*/ */
const CONFIG_ACTIVE_DIRECTORY = 'active'; const CONFIG_ACTIVE_DIRECTORY = 'active';
/**
* $config_directories key for sync directory.
*
* @see config_get_config_directory()
*/
const CONFIG_SYNC_DIRECTORY = 'sync';
/** /**
* $config_directories key for staging directory. * $config_directories key for staging directory.
* *
* @see config_get_config_directory() * @see config_get_config_directory()
* @see CONFIG_SYNC_DIRECTORY
*
* @deprecated in Drupal 8.0.x and will be removed before 9.0.0. The staging
* directory was renamed to sync.
*/ */
const CONFIG_STAGING_DIRECTORY = 'staging'; const CONFIG_STAGING_DIRECTORY = 'staging';
...@@ -130,7 +141,7 @@ ...@@ -130,7 +141,7 @@
* *
* @param string $type * @param string $type
* The type of config directory to return. Drupal core provides the * The type of config directory to return. Drupal core provides the
* CONFIG_STAGING_DIRECTORY constant to access the staging directory. * CONFIG_SYNC_DIRECTORY constant to access the sync directory.
* *
* @return string * @return string
* The configuration directory path. * The configuration directory path.
...@@ -140,6 +151,11 @@ ...@@ -140,6 +151,11 @@
function config_get_config_directory($type) { function config_get_config_directory($type) {
global $config_directories; global $config_directories;
// @todo Remove fallback in Drupal 9. https://www.drupal.org/node/2574943
if ($type == CONFIG_SYNC_DIRECTORY && !isset($config_directories[CONFIG_SYNC_DIRECTORY]) && isset($config_directories[CONFIG_STAGING_DIRECTORY])) {
$type = CONFIG_STAGING_DIRECTORY;
}
if (!empty($config_directories[$type])) { if (!empty($config_directories[$type])) {
return $config_directories[$type]; return $config_directories[$type];
} }
......
...@@ -335,7 +335,7 @@ function file_ensure_htaccess() { ...@@ -335,7 +335,7 @@ function file_ensure_htaccess() {
file_save_htaccess('private://', TRUE); file_save_htaccess('private://', TRUE);
} }
file_save_htaccess('temporary://', TRUE); file_save_htaccess('temporary://', TRUE);
file_save_htaccess(config_get_config_directory(CONFIG_STAGING_DIRECTORY), TRUE); file_save_htaccess(config_get_config_directory(CONFIG_SYNC_DIRECTORY), TRUE);
} }
/** /**
......
...@@ -362,7 +362,7 @@ function install_begin_request($class_loader, &$install_state) { ...@@ -362,7 +362,7 @@ function install_begin_request($class_loader, &$install_state) {
\Drupal::setContainer($container); \Drupal::setContainer($container);
// Determine whether base system services are ready to operate. // Determine whether base system services are ready to operate.
$install_state['config_verified'] = install_ensure_config_directory(CONFIG_STAGING_DIRECTORY); $install_state['config_verified'] = install_ensure_config_directory(CONFIG_SYNC_DIRECTORY);
$install_state['database_verified'] = install_verify_database_settings($site_path); $install_state['database_verified'] = install_verify_database_settings($site_path);
$install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified']; $install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified'];
......
...@@ -202,8 +202,8 @@ function drupal_get_database_types() { ...@@ -202,8 +202,8 @@ function drupal_get_database_types() {
* and comment properties. * and comment properties.
* @code * @code
* $settings['config_directories'] = array( * $settings['config_directories'] = array(
* CONFIG_STAGING_DIRECTORY => (object) array( * CONFIG_SYNC_DIRECTORY => (object) array(
* 'value' => 'config_hash/staging', * 'value' => 'config_hash/sync',
* 'required' => TRUE, * 'required' => TRUE,
* ), * ),
* ); * );
...@@ -211,7 +211,7 @@ function drupal_get_database_types() { ...@@ -211,7 +211,7 @@ function drupal_get_database_types() {
* gets dumped as: * gets dumped as:
* @code * @code
* $config_directories['active'] = 'config_hash/active'; * $config_directories['active'] = 'config_hash/active';
* $config_directories['staging'] = 'config_hash/staging' * $config_directories['sync'] = 'config_hash/sync'
* @endcode * @endcode
*/ */
function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
...@@ -487,9 +487,9 @@ function drupal_install_config_directories() { ...@@ -487,9 +487,9 @@ function drupal_install_config_directories() {
// manually defined in the existing already. // manually defined in the existing already.
$settings = []; $settings = [];
$config_directories_hash = Crypt::randomBytesBase64(55); $config_directories_hash = Crypt::randomBytesBase64(55);
if (empty($config_directories[CONFIG_STAGING_DIRECTORY])) { if (empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
$settings['config_directories'][CONFIG_STAGING_DIRECTORY] = (object) [ $settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/staging', 'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/sync',
'required' => TRUE, 'required' => TRUE,
]; ];
} }
...@@ -505,19 +505,19 @@ function drupal_install_config_directories() { ...@@ -505,19 +505,19 @@ function drupal_install_config_directories() {
// public files directory, which has already been verified to be writable // public files directory, which has already been verified to be writable
// itself. But if it somehow fails anyway, the installation cannot proceed. // itself. But if it somehow fails anyway, the installation cannot proceed.
// Bail out using a similar error message as in system_requirements(). // Bail out using a similar error message as in system_requirements().
if (!install_ensure_config_directory(CONFIG_STAGING_DIRECTORY)) { if (!install_ensure_config_directory(CONFIG_SYNC_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( 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), '%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
':handbook_url' => 'https://www.drupal.org/server-permissions', ':handbook_url' => 'https://www.drupal.org/server-permissions',
))); )));
} }
// Put a README.txt into the staging config directory. This is required so // Put a README.txt into the sync config directory. This is required so that
// that they can later be added to git. Since this directory is auto- // they can later be added to git. Since this directory is auto-created, we
// created, we have to write out the README rather than just adding it // have to write out the README rather than just adding it to the drupal core
// to the drupal core repo. // 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'; $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); file_put_contents(config_get_config_directory(CONFIG_SYNC_DIRECTORY) . '/README.txt', $text);
} }
/** /**
...@@ -525,7 +525,7 @@ function drupal_install_config_directories() { ...@@ -525,7 +525,7 @@ function drupal_install_config_directories() {
* *
* @param string $type * @param string $type
* Type of config directory to return. Drupal core provides 'active' and * Type of config directory to return. Drupal core provides 'active' and
* 'staging'. * 'sync'.
* *
* @return bool * @return bool
* TRUE if the config directory exists and is writable. * TRUE if the config directory exists and is writable.
......
...@@ -367,8 +367,8 @@ protected function createExtensionChangelist() { ...@@ -367,8 +367,8 @@ protected function createExtensionChangelist() {
$current_extensions = $this->storageComparer->getTargetStorage()->read('core.extension'); $current_extensions = $this->storageComparer->getTargetStorage()->read('core.extension');
$new_extensions = $this->storageComparer->getSourceStorage()->read('core.extension'); $new_extensions = $this->storageComparer->getSourceStorage()->read('core.extension');
// If there is no extension information in staging then exit. This is // If there is no extension information in sync then exit. This is probably
// probably due to an empty staging directory. // due to an empty sync directory.
if (!$new_extensions) { if (!$new_extensions) {
return; return;
} }
...@@ -780,7 +780,7 @@ protected function processConfiguration($collection, $op, $name) { ...@@ -780,7 +780,7 @@ protected function processConfiguration($collection, $op, $name) {
* The name of the extension to process. * The name of the extension to process.
*/ */
protected function processExtension($type, $op, $name) { 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 sync directory instead of the
// extensions own default config directories. // extensions own default config directories.
\Drupal::service('config.installer') \Drupal::service('config.installer')
->setSyncing(TRUE) ->setSyncing(TRUE)
......
...@@ -85,9 +85,9 @@ ...@@ -85,9 +85,9 @@
* configuration object so that they can be checked without the module that * configuration object so that they can be checked without the module that
* provides the configuration entity class being installed. This is important * provides the configuration entity class being installed. This is important
* for configuration synchronization, which needs to be able to validate * for configuration synchronization, which needs to be able to validate
* configuration in the staging directory before the synchronization has * configuration in the sync directory before the synchronization has occurred.
* occurred. Also, if you have a configuration entity object and you want to * Also, if you have a configuration entity object and you want to get the
* get the current dependencies (without recalculation), you can use * current dependencies (without recalculation), you can use
* \Drupal\Core\Config\Entity\ConfigEntityInterface::getDependencies(). * \Drupal\Core\Config\Entity\ConfigEntityInterface::getDependencies().
* *
* When uninstalling a module or a theme, configuration entities that are * When uninstalling a module or a theme, configuration entities that are
......
...@@ -25,12 +25,12 @@ static function getActive() { ...@@ -25,12 +25,12 @@ static function getActive() {
} }
/** /**
* Returns a FileStorage object working with the staging config directory. * Returns a FileStorage object working with the sync config directory.
* *
* @return \Drupal\Core\Config\FileStorage FileStorage * @return \Drupal\Core\Config\FileStorage FileStorage
*/ */
static function getStaging() { static function getSync() {
return new FileStorage(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); return new FileStorage(config_get_config_directory(CONFIG_SYNC_DIRECTORY));
} }
} }
...@@ -33,7 +33,7 @@ function config_help($route_name, RouteMatchInterface $route_match) { ...@@ -33,7 +33,7 @@ function config_help($route_name, RouteMatchInterface $route_match) {
case 'config.sync': case 'config.sync':
$output = ''; $output = '';
$output .= '<p>' . t('Compare the configuration uploaded to your staging directory with the active configuration before completing the import.') . '</p>'; $output .= '<p>' . t('Compare the configuration uploaded to your sync directory with the active configuration before completing the import.') . '</p>';
return $output; return $output;
case 'config.export_full': case 'config.export_full':
...@@ -43,7 +43,7 @@ function config_help($route_name, RouteMatchInterface $route_match) { ...@@ -43,7 +43,7 @@ function config_help($route_name, RouteMatchInterface $route_match) {
case 'config.import_full': case 'config.import_full':
$output = ''; $output = '';
$output .= '<p>' . t('Upload a full site configuration archive to the staging directory. It can then be compared and imported on the Synchronize page.') . '</p>'; $output .= '<p>' . t('Upload a full site configuration archive to the sync directory. It can then be compared and imported on the Synchronize page.') . '</p>';
return $output; return $output;
case 'config.export_single': case 'config.export_single':
......
...@@ -64,7 +64,7 @@ class ConfigController implements ContainerInjectionInterface { ...@@ -64,7 +64,7 @@ class ConfigController implements ContainerInjectionInterface {
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('config.storage'), $container->get('config.storage'),
$container->get('config.storage.staging'), $container->get('config.storage.sync'),
$container->get('config.manager'), $container->get('config.manager'),
new FileDownloadController(), new FileDownloadController(),
$container->get('diff.formatter') $container->get('diff.formatter')
......
...@@ -40,7 +40,7 @@ public function __construct(StorageInterface $config_storage) { ...@@ -40,7 +40,7 @@ public function __construct(StorageInterface $config_storage) {
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('config.storage.staging') $container->get('config.storage.sync')
); );
} }
...@@ -93,7 +93,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -93,7 +93,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
foreach ($archiver->listContent() as $file) { foreach ($archiver->listContent() as $file) {
$files[] = $file['filename']; $files[] = $file['filename'];
} }
$archiver->extractList($files, config_get_config_directory(CONFIG_STAGING_DIRECTORY)); $archiver->extractList($files, config_get_config_directory(CONFIG_SYNC_DIRECTORY));
drupal_set_message($this->t('Your configuration files were successfully uploaded and are ready for import.')); drupal_set_message($this->t('Your configuration files were successfully uploaded and are ready for import.'));
$form_state->setRedirect('config.sync'); $form_state->setRedirect('config.sync');
} }
......
...@@ -39,11 +39,11 @@ class ConfigSync extends FormBase { ...@@ -39,11 +39,11 @@ class ConfigSync extends FormBase {
protected $lock; protected $lock;
/** /**
* The staging configuration object. * The sync configuration object.
* *
* @var \Drupal\Core\Config\StorageInterface * @var \Drupal\Core\Config\StorageInterface
*/ */
protected $stagingStorage; protected $syncStorage;
/** /**
* The active configuration object. * The active configuration object.
...@@ -111,7 +111,7 @@ class ConfigSync extends FormBase { ...@@ -111,7 +111,7 @@ class ConfigSync extends FormBase {
/** /**
* Constructs the object. * Constructs the object.
* *
* @param \Drupal\Core\Config\StorageInterface $staging_storage * @param \Drupal\Core\Config\StorageInterface $sync_storage
* The source storage. * The source storage.
* @param \Drupal\Core\Config\StorageInterface $active_storage * @param \Drupal\Core\Config\StorageInterface $active_storage
* The target storage. * The target storage.
...@@ -134,8 +134,8 @@ class ConfigSync extends FormBase { ...@@ -134,8 +134,8 @@ class ConfigSync extends FormBase {
* @param \Drupal\Core\Render\RendererInterface * @param \Drupal\Core\Render\RendererInterface
* The renderer. * The renderer.
*/ */
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, RendererInterface $renderer) { public function __construct(StorageInterface $sync_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, RendererInterface $renderer) {
$this->stagingStorage = $staging_storage; $this->syncStorage = $sync_storage;
$this->activeStorage = $active_storage; $this->activeStorage = $active_storage;
$this->snapshotStorage = $snapshot_storage; $this->snapshotStorage = $snapshot_storage;
$this->lock = $lock; $this->lock = $lock;
...@@ -153,7 +153,7 @@ public function __construct(StorageInterface $staging_storage, StorageInterface ...@@ -153,7 +153,7 @@ public function __construct(StorageInterface $staging_storage, StorageInterface
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('config.storage.staging'), $container->get('config.storage.sync'),
$container->get('config.storage'), $container->get('config.storage'),
$container->get('config.storage.snapshot'), $container->get('config.storage.snapshot'),
$container->get('lock.persistent'), $container->get('lock.persistent'),
...@@ -183,8 +183,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { ...@@ -183,8 +183,8 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->t('Import all'), '#value' => $this->t('Import all'),
); );
$source_list = $this->stagingStorage->listAll(); $source_list = $this->syncStorage->listAll();
$storage_comparer = new StorageComparer($this->stagingStorage, $this->activeStorage, $this->configManager); $storage_comparer = new StorageComparer($this->syncStorage, $this->activeStorage, $this->configManager);
if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) { if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) {
$form['no_changes'] = array( $form['no_changes'] = array(
'#type' => 'table', '#type' => 'table',
......
...@@ -28,8 +28,8 @@ public function assertConfigEntityImport(ConfigEntityInterface $entity) { ...@@ -28,8 +28,8 @@ public function assertConfigEntityImport(ConfigEntityInterface $entity) {
$entity_uuid = $entity->uuid(); $entity_uuid = $entity->uuid();
$entity_type_id = $entity->getEntityTypeId(); $entity_type_id = $entity->getEntityTypeId();
$original_data = $entity->toArray(); $original_data = $entity->toArray();
// Copy everything to staging. // Copy everything to sync.
$this->copyConfig(\Drupal::service('config.storage'), \Drupal::service('config.storage.staging')); $this->copyConfig(\Drupal::service('config.storage'), \Drupal::service('config.storage.sync'));
// Delete the configuration from active. Don't worry about side effects of // Delete the configuration from active. Don't worry about side effects of
// deleting config like fields cleaning up field storages. The coming import // deleting config like fields cleaning up field storages. The coming import
// should recreate everything as necessary. // should recreate everything as necessary.
......
...@@ -28,7 +28,7 @@ class ConfigDiffTest extends KernelTestBase { ...@@ -28,7 +28,7 @@ class ConfigDiffTest extends KernelTestBase {
*/ */
function testDiff() { function testDiff() {
$active = $this->container->get('config.storage'); $active = $this->container->get('config.storage');
$staging = $this->container->get('config.storage.staging'); $sync = $this->container->get('config.storage.sync');
$config_name = 'config_test.system'; $config_name = 'config_test.system';
$change_key = 'foo'; $change_key = 'foo';
$remove_key = '404'; $remove_key = '404';
...@@ -43,44 +43,44 @@ function testDiff() { ...@@ -43,44 +43,44 @@ function testDiff() {
// Install the default config. // Install the default config.
$this->installConfig(array('config_test')); $this->installConfig(array('config_test'));
// Change a configuration value in staging. // Change a configuration value in sync.
$staging_data = $original_data; $sync_data = $original_data;
$staging_data[$change_key] = $change_data; $sync_data[$change_key] = $change_data;
$staging_data[$add_key] = $add_data; $sync_data[$add_key] = $add_data;
$staging->write($config_name, $staging_data); $sync->write($config_name, $sync_data);
// Verify that the diff reflects a change. // Verify that the diff reflects a change.
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name); $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
$edits = $diff->getEdits(); $edits = $diff->getEdits();
$this->assertEqual($edits[0]->type, 'change', 'The first item in the diff is a change.'); $this->assertEqual($edits[0]->type, 'change', 'The first item in the diff is a change.');
$this->assertEqual($edits[0]->orig[0], $change_key . ': ' . $original_data[$change_key], format_string("The active value for key '%change_key' is '%original_data'.", array('%change_key' => $change_key, '%original_data' => $original_data[$change_key]))); $this->assertEqual($edits[0]->orig[0], $change_key . ': ' . $original_data[$change_key], format_string("The active value for key '%change_key' is '%original_data'.", array('%change_key' => $change_key, '%original_data' => $original_data[$change_key])));
$this->assertEqual($edits[0]->closing[0], $change_key . ': ' . $change_data, format_string("The staging value for key '%change_key' is '%change_data'.", array('%change_key' => $change_key, '%change_data' => $change_data))); $this->assertEqual($edits[0]->closing[0], $change_key . ': ' . $change_data, format_string("The sync value for key '%change_key' is '%change_data'.", array('%change_key' => $change_key, '%change_data' => $change_data)));
// Reset data back to original, and remove a key // Reset data back to original, and remove a key
$staging_data = $original_data; $sync_data = $original_data;
unset($staging_data[$remove_key]); unset($sync_data[$remove_key]);
$staging->write($config_name, $staging_data); $sync->write($config_name, $sync_data);
// Verify that the diff reflects a removed key. // Verify that the diff reflects a removed key.
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name); $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
$edits = $diff->getEdits(); $edits = $diff->getEdits();
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.'); $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
$this->assertEqual($edits[1]->type, 'delete', 'The second item in the diff is a delete.'); $this->assertEqual($edits[1]->type, 'delete', 'The second item in the diff is a delete.');
$this->assertEqual($edits[1]->orig[0], $remove_key . ': ' . $original_data[$remove_key], format_string("The active value for key '%remove_key' is '%original_data'.", array('%remove_key' => $remove_key, '%original_data' => $original_data[$remove_key]))); $this->assertEqual($edits[1]->orig[0], $remove_key . ': ' . $original_data[$remove_key], format_string("The active value for key '%remove_key' is '%original_data'.", array('%remove_key' => $remove_key, '%original_data' => $original_data[$remove_key])));
$this->assertFalse($edits[1]->closing, format_string("The key '%remove_key' does not exist in staging.", array('%remove_key' => $remove_key))); $this->assertFalse($edits[1]->closing, format_string("The key '%remove_key' does not exist in sync.", array('%remove_key' => $remove_key)));
// Reset data back to original and add a key // Reset data back to original and add a key
$staging_data = $original_data; $sync_data = $original_data;
$staging_data[$add_key] = $add_data; $sync_data[$add_key] = $add_data;
$staging->write($config_name, $staging_data); $sync->write($config_name, $sync_data);
// Verify that the diff reflects an added key. // Verify that the diff reflects an added key.
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name); $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
$edits = $diff->getEdits(); $edits = $diff->getEdits();
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.'); $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
$this->assertEqual($edits[1]->type, 'add', 'The second item in the diff is an add.'); $this->assertEqual($edits[1]->type, 'add', 'The second item in the diff is an add.');
$this->assertFalse($edits[1]->orig, format_string("The key '%add_key' does not exist in active.", array('%add_key' => $add_key))); $this->assertFalse($edits[1]->orig, format_string("The key '%add_key' does not exist in active.", array('%add_key' => $add_key)));
$this->assertEqual($edits[1]->closing[0], $add_key . ': ' . $add_data, format_string("The staging value for key '%add_key' is '%add_data'.", array('%add_key' => $add_key, '%add_data' => $add_data))); $this->assertEqual($edits[1]->closing[0], $add_key . ': ' . $add_data, format_string("The sync value for key '%add_key' is '%add_data'.", array('%add_key' => $add_key, '%add_data' => $add_data)));
// Test diffing a renamed config entity. // Test diffing a renamed config entity.
$test_entity_id = $this->randomMachineName(); $test_entity_id = $this->randomMachineName();
...@@ -90,9 +90,9 @@ function testDiff() { ...@@ -90,9 +90,9 @@ function testDiff() {
)); ));
$test_entity->save(); $test_entity->save();
$data = $active->read('config_test.dynamic.' . $test_entity_id); $data = $active->read('config_test.dynamic.' . $test_entity_id);
$staging->write('config_test.dynamic.' . $test_entity_id, $data); $sync->write('config_test.dynamic.' . $test_entity_id, $data);
$config_name = 'config_test.dynamic.' . $test_entity_id; $config_name = 'config_test.dynamic.' . $test_entity_id;
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name, $config_name); $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name, $config_name);
// Prove the fields match. // Prove the fields match.
$edits = $diff->getEdits(); $edits = $diff->getEdits();
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.'); $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
...@@ -103,7 +103,7 @@ function testDiff() { ...@@ -103,7 +103,7 @@ function testDiff() {
$test_entity->set('id', $new_test_entity_id); $test_entity->set('id', $new_test_entity_id);
$test_entity->save(); $test_entity->save();
$diff = \Drupal::service('config.manager')->diff($active, $staging, 'config_test.dynamic.' . $new_test_entity_id, $config_name); $diff = \Drupal::service('config.manager')->diff($active, $sync, 'config_test.dynamic.' . $new_test_entity_id, $config_name);
$edits = $diff->getEdits(); $edits = $diff->getEdits();
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.'); $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
$this->assertEqual($edits[1]->type, 'change', 'The second item in the diff is a change.'); $this->assertEqual($edits[1]->type, 'change', 'The second item in the diff is a change.');
...@@ -119,27 +119,27 @@ function testDiff() { ...@@ -119,27 +119,27 @@ function testDiff() {
function testCollectionDiff() { function testCollectionDiff() {
/** @var \Drupal\Core\Config\StorageInterface $active */ /** @var \Drupal\Core\Config\StorageInterface $active */
$active = $this->container->get('config.storage'); $active = $this->container->get('config.storage');
/** @var \Drupal\Core\Config\StorageInterface $staging */ /** @var \Drupal\Core\Config\StorageInterface $sync */
$staging = $this->container->get('config.storage.staging'); $sync = $this->container->get('config.storage.sync');
$active_test_collection = $active->createCollection('test'); $active_test_collection = $active->createCollection('test');
$staging_test_collection = $staging->createCollection('test'); $sync_test_collection = $sync->createCollection('test');
$config_name = 'config_test.test'; $config_name = 'config_test.test';
$data = array('foo' => 'bar'); $data = array('foo' => 'bar');
$active->write($config_name, $data); $active->write($config_name, $data);
$staging->write($config_name, $data); $sync->write($config_name, $data);
$active_test_collection->write($config_name, $data); $active_test_collection->write($config_name, $data);
$staging_test_collection->write($config_name, array('foo' => 'baz')); $sync_test_collection->write($config_name, array('foo' => 'baz'));
// Test the fields match in the default collection diff. // Test the fields match in the default collection diff.
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name); $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
$edits = $diff->getEdits(); $edits = $diff->getEdits();
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.'); $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
$this->assertEqual(count($edits), 1, 'There is one item in the diff'); $this->assertEqual(count($edits), 1, 'There is one item in the diff');
// Test that the differences are detected when diffing the collection. // Test that the differences are detected when diffing the collection.
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name, NULL, 'test'); $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name, NULL, 'test');
$edits = $diff->getEdits(); $edits = $diff->getEdits();
$this->assertEqual($edits[0]->type, 'change', 'The second item in the diff is a copy.'); $this->assertEqual($edits[0]->type, 'change', 'The second item in the diff is a copy.');
$this->assertEqual($edits[0]->orig, array('foo: bar')); $this->assertEqual($edits[0]->orig, array('foo: bar'));
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
use Drupal\Core\Config\ConfigDuplicateUUIDException; use Drupal\Core\Config\ConfigDuplicateUUIDException;
/** /**
* Tests staging and importing config entities with IDs and UUIDs that match * Tests sync and importing config entities with IDs and UUIDs that match
* existing config. * existing config.
* *
* @group config * @group config
......
...@@ -191,21 +191,21 @@ public function testExportImport() { ...@@ -191,21 +191,21 @@ public function testExportImport() {
// Ensure the item is displayed as part of a list (to avoid false matches // Ensure the item is displayed as part of a list (to avoid false matches
// on the rest of the page) and that the list markup is not escaped. // on the rest of the page) and that the list markup is not escaped.
$this->assertRaw('<li>system.site</li>'); $this->assertRaw('<li>system.site</li>');
// Remove everything from staging. The warning about differences between the // Remove everything from sync. The warning about differences between the
// active and snapshot should no longer exist. // active and snapshot should no longer exist.
\Drupal::service('config.storage.staging')->deleteAll(); \Drupal::service('config.storage.sync')->deleteAll();
$this->drupalGet('admin/config/development/configuration'); $this->drupalGet('admin/config/development/configuration');
$this->assertNoText(t('Warning message')); $this->assertNoText(t('Warning message'));
$this->assertNoText('The following items in your active configuration have changes since the last import that may be lost on the next import.'); $this->assertNoText('The following items in your active configuration have changes since the last import that may be lost on the next import.');
$this->assertText(t('There are no configuration changes to import.')); $this->assertText(t('There are no configuration changes to import.'));
// Write a file to staging. The warning about differences between the // Write a file to sync. The warning about differences between the active
// active and snapshot should now exist. // and snapshot should now exist.
/** @var \Drupal\Core\Config\StorageInterface $staging */ /** @var \Drupal\Core\Config\StorageInterface $sync */
$staging = $this->container->get('config.storage.staging'); $sync = $this->container->get('config.storage.sync');
$data = $this->config('system.site')->get(); $data = $this->config('system.site')->get();
$data['slogan'] = 'in the face'; $data['slogan'] = 'in the face';
$this->copyConfig($this->container->get('config.storage'), $staging); $this->copyConfig($this->container->get('config.storage'), $sync);
$staging->write('system.site', $data); $sync->write('system.site', $data);
$this->drupalGet('admin/config/development/configuration'); $this->drupalGet('admin/config/development/configuration');
$this->assertText(t('Warning message'));