diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index bae5acfde2..e815f471e4 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -444,7 +444,7 @@ function install_begin_request($class_loader, &$install_state) { $install_state['theme'] = $install_state['profile_info']['distribution']['install']['theme']; } // Ensure all profile directories are registered. - $profiles = \Drupal::service('profile_handler')->getProfiles($profile); + $profiles = \Drupal::service('profile_handler')->getInheritProfiles($profile); $profile_directories = array_map(function($extension) { return $extension->getPath(); }, $profiles); @@ -1575,7 +1575,7 @@ function install_profile_themes(&$install_state) { */ function install_install_profile(&$install_state) { // Install all the profiles. - $profiles = \Drupal::service('profile_handler')->getProfiles(); + $profiles = \Drupal::service('profile_handler')->getInheritProfiles(); \Drupal::service('module_installer')->install(array_keys($profiles), FALSE); // Install all available optional config. During installation the module order diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index bcb2144df7..c53e1492a5 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -482,7 +482,7 @@ public function checkConfigurationToInstall($type, $name) { // Install profiles can not have config clashes. Configuration that // has the same name as a module's configuration will be used instead. - $profiles = $this->profileHandler->getProfiles(); + $profiles = $this->profileHandler->getInheritProfiles(); if (!isset($profiles[$name])) { // Throw an exception if the module being installed contains configuration // that already exists. Additionally, can not continue installing more diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php index 2ad1ae35a0..aa761660f5 100644 --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -125,7 +125,7 @@ protected function getAllFolders() { // default configuration. We do this by replacing the config file path // from the module/theme with the install profile version if there are // any duplicates. - $this->folders += $this->getComponentNames($this->profileHandler->getProfiles($this->installProfile)); + $this->folders += $this->getComponentNames($this->profileHandler->getInheritProfiles($this->installProfile)); } } return $this->folders; diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index fad317a4d9..c53d288aec 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -165,7 +165,7 @@ protected function getAllFolders() { $this->folders = []; $this->folders += $this->getCoreNames(); // Get dependent profiles and add the extension components. - $this->folders += $this->getComponentNames($this->profileHandler->getProfiles()); + $this->folders += $this->getComponentNames($this->profileHandler->getInheritProfiles()); // Perform an ExtensionDiscovery scan as we cannot use drupal_get_path() // yet because the system module may not yet be enabled during install. // @todo Remove as part of https://www.drupal.org/node/2186491 diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php index bb63b0770f..81561eba69 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -122,7 +122,7 @@ protected function validateModules(ConfigImporter $config_importer) { // Get a list of parent profiles and the main profile. /* @var $profiles \Drupal\Core\Extension\Extension[] */ - $profiles = \Drupal::service('profile_handler')->getProfiles(); + $profiles = \Drupal::service('profile_handler')->getInheritProfiles(); /* @var $main_profile \Drupal\Core\Extension\Extension */ $main_profile = end($profiles); diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php index 1996db4de9..83c893d78f 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -265,7 +265,7 @@ public function setProfileDirectoriesFromSettings() { // In case both profile directories contain the same extension, the actual // profile always has precedence. if ($profile) { - $profiles = $this->profileHandler->getProfiles($profile); + $profiles = $this->profileHandler->getInheritProfiles($profile); $profile_directories = array_map(function($extension) { return $extension->getPath(); }, $profiles); diff --git a/core/lib/Drupal/Core/Extension/FallbackProfileHandler.php b/core/lib/Drupal/Core/Extension/FallbackProfileHandler.php index f858ca21ab..c583546ac0 100644 --- a/core/lib/Drupal/Core/Extension/FallbackProfileHandler.php +++ b/core/lib/Drupal/Core/Extension/FallbackProfileHandler.php @@ -38,7 +38,9 @@ public function getProfileInfo($profile) { if (isset($this->profileInfo[$profile])) { return $this->profileInfo[$profile]; } - return []; + else { + throw new \InvalidArgumentException('The profile name is invalid.'); + } } /** @@ -51,14 +53,14 @@ public function setProfileInfo($profile, array $info) { /** * {@inheritdoc} */ - public function clearProfileCache() { + public function clearCache() { unset($this->profileInfo); } /** * {@inheritdoc} */ - public function getProfiles($profile = NULL) { + public function getInheritProfiles($profile = NULL) { $profile_path = drupal_get_path('profile', $profile); return [ $profile => new Extension($this->root, 'profile', $profile_path), diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 9102d7783d..ac9a0641ff 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -334,7 +334,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { if ($uninstall_dependents) { // Add dependent modules to the list. The new modules will be processed as // the while loop continues. - $profiles = \Drupal::service('profile_handler')->getProfiles(); + $profiles = \Drupal::service('profile_handler')->getInheritProfiles(); while (list($module) = each($module_list)) { foreach (array_keys($module_data[$module]->required_by) as $dependent) { if (!isset($module_data[$dependent])) { diff --git a/core/lib/Drupal/Core/Extension/ProfileHandler.php b/core/lib/Drupal/Core/Extension/ProfileHandler.php index b429972fdb..cbc7294132 100644 --- a/core/lib/Drupal/Core/Extension/ProfileHandler.php +++ b/core/lib/Drupal/Core/Extension/ProfileHandler.php @@ -198,7 +198,7 @@ public function setProfileInfo($profile, array $info) { /** * {@inheritdoc} */ - public function clearProfileCache() { + public function clearCache() { $this->profilesWithParentsCache = []; $this->infoCache = []; } @@ -249,7 +249,7 @@ protected function getProfileList($profile) { /** * {@inheritdoc} */ - public function getProfiles($profile = NULL) { + public function getInheritProfiles($profile = NULL) { if (empty($profile)) { $profile = drupal_get_profile(); } diff --git a/core/lib/Drupal/Core/Extension/ProfileHandlerInterface.php b/core/lib/Drupal/Core/Extension/ProfileHandlerInterface.php index 37b4bdf002..c6221e4839 100644 --- a/core/lib/Drupal/Core/Extension/ProfileHandlerInterface.php +++ b/core/lib/Drupal/Core/Extension/ProfileHandlerInterface.php @@ -10,7 +10,7 @@ /** * Retrieve the info array for a profile. * - * Parse and process the profile info.yml file. + * Parses and processes the profile info.yml file. * Processing steps: * 1) Ensure default keys are set. * 2) Recursively collect dependencies from parent profiles. @@ -24,6 +24,9 @@ * @return array * The processed $info array. * + * @throws \InvalidArgumentException + * If the profile name is invalid. + * * @see install_profile_info() */ public function getProfileInfo($profile); @@ -46,7 +49,7 @@ public function setProfileInfo($profile, array $info); /** * Clears the profile cache. */ - public function clearProfileCache(); + public function clearCache(); /** * Returns a list of dependent installation profiles. @@ -59,7 +62,7 @@ public function clearProfileCache(); * descending order of their dependencies. * (parent profiles first, main profile last) */ - public function getProfiles($profile = NULL); + public function getInheritProfiles($profile = NULL); /** * Select the install distribution from the list of profiles. diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php index bcd60652ba..1e4c09760c 100644 --- a/core/modules/system/src/Form/ModulesUninstallForm.php +++ b/core/modules/system/src/Form/ModulesUninstallForm.php @@ -114,7 +114,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { return $form; } - $profiles = \Drupal::service('profile_handler')->getProfiles(); + $profiles = \Drupal::service('profile_handler')->getInheritProfiles(); // Sort all modules by their name. uasort($uninstallable, 'system_sort_modules_by_info_name'); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 3d013178a7..ad12cb0b5b 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1000,7 +1000,7 @@ function _system_rebuild_module_data() { // Find profiles. /** @var \Drupal\Core\Extension\ProfileHandlerInterface $profile_handler */ $profile_handler = \Drupal::service('profile_handler'); - $modules = array_merge($modules, $profile_handler->getProfiles()); + $modules = array_merge($modules, $profile_handler->getInheritProfiles()); // Set defaults for module info. $defaults = [ @@ -1044,7 +1044,7 @@ function _system_rebuild_module_data() { } // This must be done after _system_rebuild_module_data_ensure_required(). - $profiles = \Drupal::service('profile_handler')->getProfiles(); + $profiles = \Drupal::service('profile_handler')->getInheritProfiles(); foreach ($profiles as $profile_name => $profile) { if (isset($modules[$profile_name])) { // Installation profiles are required, if it's a valid module. diff --git a/core/profiles/testing_subsubprofile/testing_subsubprofile.info.yml b/core/profiles/testing_subsubprofile/testing_subsubprofile.info.yml new file mode 100644 index 0000000000..2a86d48778 --- /dev/null +++ b/core/profiles/testing_subsubprofile/testing_subsubprofile.info.yml @@ -0,0 +1,14 @@ +name: Testing SubSubProfile +type: profile +description: 'Profile for testing deep profile inheritance.' +version: VERSION +core: 8.x +hidden: true + +base profile: + name: testing_inherited + excluded_dependencies: + - block + +dependencies: + - page_cache diff --git a/core/profiles/testing_subsubprofile/tests/src/Functional/DeepInheritedProfileTest.php b/core/profiles/testing_subsubprofile/tests/src/Functional/DeepInheritedProfileTest.php new file mode 100644 index 0000000000..27a4a6f08e --- /dev/null +++ b/core/profiles/testing_subsubprofile/tests/src/Functional/DeepInheritedProfileTest.php @@ -0,0 +1,34 @@ +assertEquals('stable', $this->config('system.theme')->get('default')); + + // Check that page_cache is enabled. Was enabled in parent-parent-profile, + // disabled in parent and re-enabled in this profile. + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('page_cache')); + // Check that block is disabled. Was enabled in parent-profile and disabled + // in this. + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('block')); + } + +} diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ProfileHandlerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ProfileHandlerTest.php index ebb20f6a00..e547978643 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ProfileHandlerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ProfileHandlerTest.php @@ -64,11 +64,14 @@ public function testGetProfileInfo() { /** * Tests getting profile dependency list. * - * @covers ::getProfiles + * @covers ::getInheritProfiles */ public function testGetProfiles() { $profile_handler = $this->container->get('profile_handler'); - $profiles = $profile_handler->getProfiles('testing_inherited'); + $profiles = $profile_handler->getInheritProfiles('testing_subsubprofile'); + $this->assertCount(3, $profiles); + + $profiles = $profile_handler->getInheritProfiles('testing_inherited'); $this->assertCount(2, $profiles); $first_profile = current($profiles);