diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index aed688d8be7..6c8a0a7e4ec 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -2338,13 +2338,12 @@ function install_config_import_batch() { \Drupal::configFactory()->getEditable('system.site')->set('uuid', $system_site['uuid'])->save(); // Create the storage comparer and the config importer. - $config_manager = \Drupal::service('config.manager'); - $storage_comparer = new StorageComparer($sync, \Drupal::service('config.storage'), $config_manager); + $storage_comparer = new StorageComparer($sync, \Drupal::service('config.storage')); $storage_comparer->createChangelist(); $config_importer = new ConfigImporter( $storage_comparer, \Drupal::service('event_dispatcher'), - $config_manager, + \Drupal::service('config.manager'), \Drupal::service('lock.persistent'), \Drupal::service('config.typed'), \Drupal::service('module_handler'), @@ -2409,14 +2408,13 @@ function install_config_download_translations(&$install_state) { function install_config_revert_install_changes() { global $install_state; - $config_manager = \Drupal::service('config.manager'); - $storage_comparer = new StorageComparer(\Drupal::service('config.storage.sync'), \Drupal::service('config.storage'), $config_manager); + $storage_comparer = new StorageComparer(\Drupal::service('config.storage.sync'), \Drupal::service('config.storage')); $storage_comparer->createChangelist(); if ($storage_comparer->hasChanges()) { $config_importer = new ConfigImporter( $storage_comparer, \Drupal::service('event_dispatcher'), - $config_manager, + \Drupal::service('config.manager'), \Drupal::service('lock.persistent'), \Drupal::service('config.typed'), \Drupal::service('module_handler'), diff --git a/core/lib/Drupal/Core/Config/StorageComparer.php b/core/lib/Drupal/Core/Config/StorageComparer.php index 30958cee1ed..e362493ac30 100644 --- a/core/lib/Drupal/Core/Config/StorageComparer.php +++ b/core/lib/Drupal/Core/Config/StorageComparer.php @@ -40,13 +40,6 @@ class StorageComparer implements StorageComparerInterface { */ protected $targetStorages; - /** - * The configuration manager. - * - * @var \Drupal\Core\Config\ConfigManagerInterface - */ - protected $configManager; - /** * List of changes to between the source storage and the target storage. * @@ -96,9 +89,9 @@ class StorageComparer implements StorageComparerInterface { * @param \Drupal\Core\Config\StorageInterface $target_storage * Storage object used to write configuration. * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager - * The configuration manager. + * (deprecated) The configuration manager. The $config_manager parameter is deprecated since version 8.7.0 and will be removed in 9.0.0. */ - public function __construct(StorageInterface $source_storage, StorageInterface $target_storage, ConfigManagerInterface $config_manager) { + public function __construct(StorageInterface $source_storage, StorageInterface $target_storage, ConfigManagerInterface $config_manager = NULL) { // Wrap the storages in a static cache so that multiple reads of the same // raw configuration object are not costly. $this->sourceCacheStorage = new MemoryBackend(); @@ -111,8 +104,11 @@ class StorageComparer implements StorageComparerInterface { $target_storage, $this->targetCacheStorage ); - $this->configManager = $config_manager; $this->changelist[StorageInterface::DEFAULT_COLLECTION] = $this->getEmptyChangelist(); + + if ($config_manager !== NULL) { + @trigger_error('The storage comparer does not need a config manager. The parameter is deprecated since version 8.7.0 and will be removed in 9.0.0. Omit the third parameter. See https://www.drupal.org/node/2993271.', E_USER_DEPRECATED); + } } /** diff --git a/core/modules/config/src/Form/ConfigSingleImportForm.php b/core/modules/config/src/Form/ConfigSingleImportForm.php index 83e776c0b0c..91b6d3812bd 100644 --- a/core/modules/config/src/Form/ConfigSingleImportForm.php +++ b/core/modules/config/src/Form/ConfigSingleImportForm.php @@ -339,11 +339,7 @@ class ConfigSingleImportForm extends ConfirmFormBase { if (!$form_state->getErrors()) { $source_storage = new StorageReplaceDataWrapper($this->configStorage); $source_storage->replaceData($config_name, $data); - $storage_comparer = new StorageComparer( - $source_storage, - $this->configStorage, - $this->configManager - ); + $storage_comparer = new StorageComparer($source_storage, $this->configStorage); if (!$storage_comparer->createChangelist()->hasChanges()) { $form_state->setErrorByName('import', $this->t('There are no changes to import.')); diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index 57fb1d860e0..8cbab3b973c 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -180,7 +180,7 @@ class ConfigSync extends FormBase { '#value' => $this->t('Import all'), ]; $source_list = $this->syncStorage->listAll(); - $storage_comparer = new StorageComparer($this->syncStorage, $this->activeStorage, $this->configManager); + $storage_comparer = new StorageComparer($this->syncStorage, $this->activeStorage); if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) { $form['no_changes'] = [ '#type' => 'table', @@ -199,7 +199,7 @@ class ConfigSync extends FormBase { // A list of changes will be displayed, so check if the user should be // warned of potential losses to configuration. if ($this->snapshotStorage->exists('core.extension')) { - $snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage, $this->configManager); + $snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage); if (!$form_state->getUserInput() && $snapshot_comparer->createChangelist()->hasChanges()) { $change_list = []; foreach ($snapshot_comparer->getAllCollectionNames() as $collection) { diff --git a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php index 7d37bc49099..01210c37e2b 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php @@ -136,8 +136,7 @@ class ConfigImportAllTest extends ModuleTestBase { // Ensure that we have no configuration changes to import. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $this->assertIdentical($storage_comparer->createChangelist()->getChangelist(), $storage_comparer->getEmptyChangelist()); diff --git a/core/modules/config/tests/src/Kernel/ConfigUninstallViaCliImportTest.php b/core/modules/config/tests/src/Kernel/ConfigUninstallViaCliImportTest.php index 722546fe303..09f5d09aa3c 100644 --- a/core/modules/config/tests/src/Kernel/ConfigUninstallViaCliImportTest.php +++ b/core/modules/config/tests/src/Kernel/ConfigUninstallViaCliImportTest.php @@ -38,8 +38,7 @@ class ConfigUninstallViaCliImportTest extends KernelTestBase { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $this->configImporter = new ConfigImporter( $storage_comparer->createChangelist(), diff --git a/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php b/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php index 0fe6b9f6e0b..6cbfe597acf 100644 --- a/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php +++ b/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php @@ -40,8 +40,7 @@ class ContentTranslationConfigImportTest extends KernelTestBase { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $this->configImporter = new ConfigImporter( $storage_comparer->createChangelist(), diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php index fef464ed7f2..5b40e3318d0 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php @@ -39,8 +39,7 @@ class ConfigImportRecreateTest extends KernelTestBase { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $this->configImporter = new ConfigImporter( $storage_comparer->createChangelist(), diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php index f52b3956ab9..7378da161e8 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php @@ -44,8 +44,7 @@ class ConfigImportRenameValidationTest extends KernelTestBase { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $this->configImporter = new ConfigImporter( $storage_comparer->createChangelist(), diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php index db09e3f9f66..a4b08475634 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php @@ -44,8 +44,7 @@ class ConfigImporterMissingContentTest extends KernelTestBase { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $this->configImporter = new ConfigImporter( $storage_comparer->createChangelist(), diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php index c8eb231a97c..6489b06799e 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php @@ -49,8 +49,7 @@ class ConfigImporterTest extends KernelTestBase { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $this->configImporter = new ConfigImporter( $storage_comparer->createChangelist(), diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php index 645638d8323..4bc2e25f20a 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php @@ -38,13 +38,12 @@ class ConfigSnapshotTest extends KernelTestBase { $active = $this->container->get('config.storage'); $sync = $this->container->get('config.storage.sync'); $snapshot = $this->container->get('config.storage.snapshot'); - $config_manager = $this->container->get('config.manager'); $config_name = 'config_test.system'; $config_key = 'foo'; $new_data = 'foobar'; - $active_snapshot_comparer = new StorageComparer($active, $snapshot, $config_manager); - $sync_snapshot_comparer = new StorageComparer($sync, $snapshot, $config_manager); + $active_snapshot_comparer = new StorageComparer($active, $snapshot); + $sync_snapshot_comparer = new StorageComparer($sync, $snapshot); // Verify that we have an initial snapshot that matches the active // configuration. This has to be true as no config should be installed. diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php index 001d9ba3dee..1b22b20a5ce 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php @@ -52,8 +52,7 @@ class ContentEntityNullStorageTest extends KernelTestBase { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $config_importer = new ConfigImporter( $storage_comparer->createChangelist(), diff --git a/core/tests/Drupal/Tests/ConfigTestTrait.php b/core/tests/Drupal/Tests/ConfigTestTrait.php index 330ff470e29..5bab85949fe 100644 --- a/core/tests/Drupal/Tests/ConfigTestTrait.php +++ b/core/tests/Drupal/Tests/ConfigTestTrait.php @@ -22,8 +22,7 @@ trait ConfigTestTrait { // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( $this->container->get('config.storage.sync'), - $this->container->get('config.storage'), - $this->container->get('config.manager') + $this->container->get('config.storage') ); $this->configImporter = new ConfigImporter( $storage_comparer, diff --git a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php index 353e6d3c7b0..9a1dd596abb 100644 --- a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php +++ b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php @@ -22,11 +22,6 @@ class StorageComparerTest extends UnitTestCase { */ protected $targetStorage; - /** - * @var \Drupal\Core\Config\ConfigManager|\PHPUnit_Framework_MockObject_MockObject - */ - protected $configManager; - /** * The storage comparer to test. * @@ -44,8 +39,7 @@ class StorageComparerTest extends UnitTestCase { protected function setUp() { $this->sourceStorage = $this->getMock('Drupal\Core\Config\StorageInterface'); $this->targetStorage = $this->getMock('Drupal\Core\Config\StorageInterface'); - $this->configManager = $this->getMock('Drupal\Core\Config\ConfigManagerInterface'); - $this->storageComparer = new StorageComparer($this->sourceStorage, $this->targetStorage, $this->configManager); + $this->storageComparer = new StorageComparer($this->sourceStorage, $this->targetStorage); } protected function getConfigData() { @@ -244,4 +238,13 @@ class StorageComparerTest extends UnitTestCase { $this->assertEmpty($this->storageComparer->getChangelist('delete')); } + /** + * @expectedDeprecation The storage comparer does not need a config manager. The parameter is deprecated since version 8.7.0 and will be removed in 9.0.0. Omit the third parameter. See https://www.drupal.org/node/2993271. + * @group legacy + */ + public function testConfigManagerDeprecation() { + $configManager = $this->getMock('Drupal\Core\Config\ConfigManagerInterface'); + new StorageComparer($this->sourceStorage, $this->targetStorage, $configManager); + } + }