diff -u b/core/includes/install.core.inc b/core/includes/install.core.inc --- b/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1197,6 +1197,8 @@ * - For non-interactive installations via install_drupal() settings. * - A discovered profile that is a distribution. If multiple profiles are * distributions, then the first discovered profile will be selected. + * If an inherited profile is detected that is a distribution, it will be + * chosen over its base profile. * - Only one visible profile is available. * * @param array $install_state @@ -1219,11 +1221,8 @@ } } // Check for a distribution profile. - foreach ($install_state['profiles'] as $profile) { - $profile_info = install_profile_info($profile->getName()); - if (!empty($profile_info['distribution'])) { - return $profile->getName(); - } + if ($distribution = \Drupal::service('profile_handler')->selectDistribution($install_state['profiles'])) { + return $distribution->getName(); } // Get all visible (not hidden) profiles. diff -u b/core/lib/Drupal/Core/Extension/ProfileHandler.php b/core/lib/Drupal/Core/Extension/ProfileHandler.php --- b/core/lib/Drupal/Core/Extension/ProfileHandler.php +++ b/core/lib/Drupal/Core/Extension/ProfileHandler.php @@ -167,13 +167,6 @@ // otherwise in the .info.yml file. $info['hidden'] = isset($info['hidden']) ? $info['hidden'] : TRUE; - // Add a default distribution name if the profile did not provide one. - // @see install_profile_info() - // @see drupal_install_profile_distribution_name() - if (!isset($info['distribution']['name'])) { - $info['distribution']['name'] = 'Drupal'; - } - $this->info_cache[$profile] = $info; } return $this->info_cache[$profile]; @@ -255,6 +248,28 @@ /** * {@inheritdoc} */ + public function selectDistribution($profile_list) { + // First, find all profiles marked as distributions + $distributions = array(); + foreach ($profile_list as $profile) { + $profile_info = $this->getProfileInfo($profile->getName()); + if (!empty($profile_info['distribution'])) { + $distributions[$profile->getName()] = $profile; + } + } + // Remove any base profiles. + foreach ($profile_list as $profile) { + $profile_info = $this->getProfileInfo($profile->getName()); + if ($base_profile = self::getProfileBaseName($profile_info)) { + unset($distributions[$base_profile]); + } + } + return !empty($distributions) ? current($distributions) : NULL; + } + + /** + * {@inheritdoc} + */ static public function getProfileBaseName($info) { return !empty($info['base profile']['name']) ? $info['base profile']['name'] diff -u b/core/lib/Drupal/Core/Extension/ProfileHandlerInterface.php b/core/lib/Drupal/Core/Extension/ProfileHandlerInterface.php --- b/core/lib/Drupal/Core/Extension/ProfileHandlerInterface.php +++ b/core/lib/Drupal/Core/Extension/ProfileHandlerInterface.php @@ -40,6 +40,20 @@ public function getProfiles($profile = NULL); /** + * Select the install distribution from the list of profiles. + * + * If there are multiple profiles marked as distributions, select the first. + * If there is an inherited profile marked as a distribution, select it over + * its base profile. + * + * @param \Drupal\Core\Extension\Extension[] $profile_list + * List of profiles to search. + * @return \Drupal\Core\Extension\Extension + * The selected distribution, or NULL if none is found. + */ + public function selectDistribution($profile_list); + + /** * Return the name of a profile from its info. * * The info array can reference a "base profile" in two ways: diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1012,6 +1012,12 @@ if ($profile && isset($modules[$profile])) { // The installation profile is required, if it's a valid module. $modules[$profile]->info['required'] = TRUE; + // Add a default distribution name if the profile did not provide one. + // @see install_profile_info() + // @see drupal_install_profile_distribution_name() + if (!isset($modules[$profile]->info['distribution']['name'])) { + $modules[$profile]->info['distribution']['name'] = 'Drupal'; + } } return $modules; only in patch2: unchanged: --- /dev/null +++ b/core/profiles/testing_inherited/src/Tests/InheritedProfileTest.php @@ -0,0 +1,29 @@ +drupalGet(''); + // Check the login block is present. + $this->assertLink(t('Create new account')); + $this->assertResponse(200); + // Check that proper modules were enabled or not. + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('config')); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('dblog')); + } + +}