diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php index 9103ab8c07..b97b40f4ce 100644 --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -29,7 +29,9 @@ class ExtensionInstallStorage extends InstallStorage { /** * The name of the currently active installation profile. * - * @var string + * In the early installer this value can be NULL. + * + * @var string|NULL */ protected $installProfile; @@ -41,26 +43,27 @@ class ExtensionInstallStorage extends InstallStorage { * themes is stored. * @param string $directory * The directory to scan in each extension to scan for files. Defaults to - * 'config/install'. + * 'config/install'. This parameter will be mandatory in Drupal 9.0.0. * @param string $collection * (optional) The collection to store configuration in. Defaults to the - * default collection. + * default collection. This parameter will be mandatory in Drupal 9.0.0. * @param bool $include_profile * (optional) Whether to include the install profile in extensions to - * search and to get overrides from. - * @param string $profile + * search and to get overrides from. This parameter will be mandatory in + * Drupal 9.0.0. + * @param string|null $profile * (optional) The current installation profile. This parameter will be - * mandatory in Drupal 9.0.0. In Drupal 8.3.0 not providing this parameter - * will trigger a silenced deprecation warning. + * mandatory in Drupal 9.0.0. */ public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION, $include_profile = TRUE, $profile = NULL) { parent::__construct($directory, $collection); $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); + if (count(func_get_args()) < 5) { + $profile = \Drupal::installProfile(); + @trigger_error('All \Drupal\Core\Config\ExtensionInstallStorage::__construct() arguments will be required in Drupal 9.0. See https://www.drupal.org/node/2538996', 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..2e96588761 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Config/ExtensionInstallStorageTest.php @@ -0,0 +1,59 @@ +prophesize(StorageInterface::class)->reveal(); + $container = new ContainerBuilder(); + $container->setParameter('install_profile', $container_profile); + \Drupal::setContainer($container); + $storage = new TestExtensionInstallStorage($config_storage); + $this->assertSame($container_profile, $storage->getProfile()); + } + + /** + * Data provider for ::testProfileDeprecation + */ + public function providerTestProfileDeprecation() { + return [ + 'null profile' => [NULL], + 'test profile' => ['test'], + ]; + } + +} + +class TestExtensionInstallStorage extends ExtensionInstallStorage { + + /** + * Gets the install profile value. + * + * @return string|null + */ + public function getProfile() { + return $this->installProfile; + } + +} diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 4265028db6..25297d7f5b 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -118,7 +118,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.',