diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index 7c48dd5..af03103 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -36,18 +36,25 @@ class ConfigSync extends FormBase { protected $lock; /** - * The source configuration object. + * The staging configuration object. * * @var \Drupal\Core\Config\StorageInterface */ - protected $sourceStorage; + protected $stagingStorage; /** - * The target configuration object. + * The active configuration object. * * @var \Drupal\Core\Config\StorageInterface */ - protected $targetStorage; + protected $activeStorage; + + /** + * The snapshot configuration object. + * + * @var \Drupal\Core\Config\StorageInterface + */ + protected $snapshotStorage; /** * Event dispatcher. @@ -94,9 +101,11 @@ class ConfigSync extends FormBase { /** * Constructs the object. * - * @param \Drupal\Core\Config\StorageInterface $sourceStorage + * @param \Drupal\Core\Config\StorageInterface $staging_storage * The source storage object. - * @param \Drupal\Core\Config\StorageInterface $targetStorage + * @param \Drupal\Core\Config\StorageInterface $active_storage + * The target storage manager. + * @param \Drupal\Core\Config\StorageInterface $snapshot_storage * The target storage manager. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock object. @@ -113,9 +122,10 @@ class ConfigSync extends FormBase { * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler */ - public function __construct(StorageInterface $sourceStorage, StorageInterface $targetStorage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, UrlGeneratorInterface $url_generator, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) { - $this->sourceStorage = $sourceStorage; - $this->targetStorage = $targetStorage; + public function __construct(StorageInterface $staging_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, UrlGeneratorInterface $url_generator, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) { + $this->stagingStorage = $staging_storage; + $this->activeStorage = $active_storage; + $this->snapshotStorage = $snapshot_storage; $this->lock = $lock; $this->eventDispatcher = $event_dispatcher; $this->configManager = $config_manager; @@ -132,6 +142,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('config.storage.staging'), $container->get('config.storage'), + $container->get('config.storage.snapshot'), $container->get('lock'), $container->get('event_dispatcher'), $container->get('config.manager'), @@ -153,14 +164,18 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { + $snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage, $this->configManager); + if (empty($form_state['input']) && $snapshot_comparer->createChangelist()->hasChanges()) { + drupal_set_message($this->t('Changes have been made to your active configuration, which might be lost on the next synchronization.'), 'warning'); + } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => $this->t('Import all'), ); - $source_list = $this->sourceStorage->listAll(); - $storage_comparer = new StorageComparer($this->sourceStorage, $this->targetStorage, $this->configManager); + $source_list = $this->stagingStorage->listAll(); + $storage_comparer = new StorageComparer($this->stagingStorage, $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/ConfigExportImportUITest.php b/core/modules/config/src/Tests/ConfigExportImportUITest.php index bd0c70f..8b691af 100644 --- a/core/modules/config/src/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php @@ -120,6 +120,17 @@ public function testExportImport() { $this->drupalGet('node/add'); $this->assertFieldByName("{$this->field->name}[0][value]", '', 'Widget is displayed'); + + \Drupal::config('system.site') + ->set('slogan', $this->originalSlogan) + ->save(); + $this->drupalGet('admin/config/development/configuration'); + $this->assertText('Changes have been made to your active configuration, which might be lost on the next synchronization.'); + $this->drupalPostForm('admin/config/development/configuration', array(), 'Import all'); + $this->drupalGet('admin/config/development/configuration'); + $this->assertNoText(t('Changes have been made to your active configuration, which might be lost on the next synchronization.')); + $this->assertText(t('There are no configuration changes.')); + } /**