diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php index 9103ab8c07..5241ff3a19 100644 --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -58,9 +58,14 @@ public function __construct(StorageInterface $config_storage, $directory = self: $this->configStorage = $config_storage; $this->includeProfile = $include_profile; if (is_null($profile)) { - @trigger_error('Install profile will be a mandatory parameter in Drupal 9.0.', E_USER_DEPRECATED); + $profile = \Drupal::installProfile(); + if (!is_null($profile)) { + // Only trigger deprecation if \Drupal::installProfile() is not also + // NULL. + @trigger_error('Install profile will be a mandatory parameter in Drupal 9.0.', E_USER_DEPRECATED); + } } - $this->installProfile = $profile ?: \Drupal::installProfile(); + $this->installProfile = $profile; } /** diff --git a/core/tests/Drupal/Tests/Core/Config/ExtensionInstallStorageTest.php b/core/tests/Drupal/Tests/Core/Config/ExtensionInstallStorageTest.php new file mode 100644 index 0000000000..65762f91b9 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Config/ExtensionInstallStorageTest.php @@ -0,0 +1,51 @@ +expectedDeprecations(['Install profile will be a mandatory parameter in Drupal 9.0.']); + } + $config_storage = $this->prophesize(StorageInterface::class)->reveal(); + $container = new ContainerBuilder(); + $container->setParameter('install_profile', $container_profile); + \Drupal::setContainer($container); + new ExtensionInstallStorage($config_storage, ExtensionInstallStorage::CONFIG_INSTALL_DIRECTORY, ExtensionInstallStorage::DEFAULT_COLLECTION, TRUE, $profile); + $this->addToAssertionCount(1); + } + + /** + * Data provider for ::testProfileDeprecation + */ + public function providerTestProfileDeprecation() { + return [ + 'both null' => [NULL, NULL], + 'constructor null' => [NULL, 'test', TRUE], + 'constructor null' => ['test', 'test'], + ]; + } + +} diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index f506af69ce..5e26be20cb 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -107,7 +107,6 @@ private function willBeIsolated($test) { */ public static function getSkippedDeprecations() { return [ - 'Install profile will be a mandatory parameter in Drupal 9.0.', 'MigrateCckField is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.', 'MigrateCckFieldPluginManager is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManager instead.', 'MigrateCckFieldPluginManagerInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManagerInterface instead.',