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 @@ -1221,8 +1221,8 @@ } } // Check for a distribution profile. - if ($distribution = \Drupal::service('profile_handler')->selectDistributionExtension($install_state['profiles'])) { - return $distribution->getName(); + if ($distribution = \Drupal::service('profile_handler')->selectDistribution(array_keys($install_state['profiles']))) { + return $distribution; } // 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 @@ -137,6 +137,10 @@ 'version' => NULL, 'hidden' => FALSE, 'php' => DRUPAL_MINIMUM_PHP, + 'base profile' => [ + 'name' => '', + 'excluded_dependencies' => [] + ], ]; $profile_path = $this->getProfilePath($profile); @@ -144,16 +148,22 @@ $info = $this->infoParser->parse($profile_file); $info += $defaults; + // Normalize any base profile info. + if (is_string($info['base profile'])) { + $info['base profile'] = [ + 'name' => $info['base profile'], + 'excluded_dependencies' => [], + ]; + } + $profile_list = []; // Get the base profile dependencies. - $base_profile_name = ProfileHandler::getProfileBaseName($info); - if ($base_profile_name) { + if ($base_profile_name = $info['base profile']['name']) { $base_info = $this->getProfileInfo($base_profile_name); $profile_list += $base_info['profile_list']; // Ensure all dependencies are cleanly merged. $info['dependencies'] = array_merge($info['dependencies'], $base_info['dependencies']); - $info['base profile'] += ['excluded_dependencies' => []]; // Apply excluded dependencies. $info['dependencies'] = array_diff($info['dependencies'], $info['base profile']['excluded_dependencies']); // Ensure there's no circular dependency. @@ -284,32 +294,9 @@ $profile_info = $this->getProfileInfo($profile_name); - if ($base_profile = self::getProfileBaseName($profile_info)) { + if ($base_profile = $profile_info['base profile']['name']) { unset($distributions[$base_profile]); } } return !empty($distributions) ? current($distributions) : NULL; } - /** - * {@inheritdoc} - */ - public function selectDistributionExtension($profile_extension_list) { - $profile_list = array_map(function (Extension $profile) { - return $profile->getName(); - }, $profile_extension_list); - - if ($distribution_name = $this->selectDistribution($profile_list)) { - return $profile_extension_list[$distribution_name]; - } - return NULL; - } - - /** - * {@inheritdoc} - */ - static public function getProfileBaseName($info) { - return !empty($info['base profile']['name']) - ? $info['base profile']['name'] - : (!empty($info['base profile']) ? $info['base profile'] : ''); - } - } 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 @@ -33,7 +33,7 @@ * This is used for testing. * * @param string $profile - * THe name of profile. + * The name of profile. * @param array $info * The info array to be set. */ @@ -48,7 +48,7 @@ * Returns a list of dependent installation profiles. * * @param string $profile - * Name of profile. If none is specified, use the current profile. + * The name of profile. If none is specified, use the current profile. * * @return \Drupal\Core\Extension\Extension[] * An associative array of Extension objects, keyed by profile name in @@ -67,45 +67,9 @@ * @param string[] $profile_list - * List of profiles names to search. + * List of profile names to search. * * @return string|null - * The selected distribution, or NULL if none is found. + * The selected distribution profile name, or NULL if none is found. */ public function selectDistribution($profile_list); - /** - * 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_extension_list - * List of profile extensions to search. - * - * @return \Drupal\Core\Extension\Extension|null - * The selected distribution, or NULL if none is found. - */ - public function selectDistributionExtension($profile_extension_list); - - /** - * Return the name of a profile from its info. - * - * The info array can reference a "base profile" in two ways: - * 1) Along with excluded dependency data: - * base profile: - * name: base_profile_name - * excluded_dependencies: - * - array of excluded module dependencies - * 2) or, a shortcut of just the name: - * base profile: base_profile_name - * - * @param array $info - * The parsed info.yml array for the profile. - * - * @return string - * The name of the base (parent) profile. - * - */ - static public function getProfileBaseName($info); - } diff -u b/core/tests/Drupal/KernelTests/Core/Extension/ProfileHandlerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ProfileHandlerTest.php --- b/core/tests/Drupal/KernelTests/Core/Extension/ProfileHandlerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ProfileHandlerTest.php @@ -27,14 +27,14 @@ * Tests getting profile info. * * @covers ::getProfileInfo - * @covers ::getProfileBaseName */ public function testGetProfileInfo() { $profile_handler = $this->container->get('profile_handler'); $info = $profile_handler->getProfileInfo('testing_inherited'); $this->assertNotEmpty($info); - $this->assertEquals(ProfileHandler::getProfileBaseName($info), 'minimal'); $this->assertEquals($info['name'], 'Testing Inherited'); + $this->assertEquals($info['base profile']['name'], 'minimal'); + $this->assertEquals($info['base profile']['excluded_dependencies'], ['dblog']); $this->assertTrue(in_array('config', $info['dependencies'], 'config should be found in dependencies')); $this->assertFalse(in_array('dblog', $info['dependencies'], 'dblog should not be found in dependencies')); $this->assertTrue($info['hidden'], 'Profiles should be hidden'); @@ -45,6 +45,10 @@ 'minimal' => 'minimal', 'testing_inherited' => 'testing_inherited' ]); + + // Test that profiles without any base return normalized info. + $info = $profile_handler->getProfileInfo('minimal'); + $this->assertEquals($info['base profile'], ['name' => '', 'excluded_dependencies' => []]); } /** @@ -102,32 +106,2 @@ - /** - * @covers ::selectDistribution - * @covers ::setProfileInfo - */ - public function testSelectDistributionExtension() { - /** @var \Drupal\Core\Extension\ProfileHandler $profile_handler */ - $profile_handler = $this->container->get('profile_handler'); - $profiles = $profile_handler->getProfiles('testing_inherited'); - $base_info = $profile_handler->getProfileInfo('minimal'); - $profile_info = $profile_handler->getProfileInfo('testing_inherited'); - - // Neither profile has distribution set - $distribution = $profile_handler->selectDistributionExtension($profiles); - $this->assertEmpty($distribution, 'No distribution should be selected'); - - // Set base profile distribution - $base_info['distribution']['name'] = 'Minimal'; - $profile_handler->setProfileInfo('minimal', $base_info); - // Base profile distribution should not be selected - $distribution = $profile_handler->selectDistributionExtension($profiles); - $this->assertEmpty($distribution, 'Base profile distribution should not be selected'); - - // Set main profile distribution - $profile_info['distribution']['name'] = 'Testing Inherited'; - $profile_handler->setProfileInfo('testing_inherited', $profile_info); - // Main profile distribution should be selected - $distribution = $profile_handler->selectDistributionExtension($profiles); - $this->assertEquals($distribution, $profiles['testing_inherited']); - } - }