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 @@ -442,7 +442,7 @@ } // Ensure all profile directories are registered. $profile_handler = \Drupal::service('profile_handler'); - $profile_directories = $profile_handler->getProfileDirectories($profile); + $profile_directories = $profile_handler->getProfileDependencies($profile); $listing->setProfileDirectories($profile_directories); } @@ -1556,10 +1556,10 @@ */ function install_install_profile(&$install_state) { $profile_handler = \Drupal::service('profile_handler'); - $profiles = $profile_handler->getProfileDependencies(drupal_get_profile()); + $profiles = $profile_handler->getProfileDependencies(); // Install all the profiles. - \Drupal::service('module_installer')->install($profiles, FALSE); + \Drupal::service('module_installer')->install(array_keys($profiles), FALSE); // Install all available optional config. During installation the module order // is determined by dependencies. If there are no dependencies between modules // then the order in which they are installed is dependent on random factors diff -u b/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php --- b/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -473,7 +473,8 @@ // Install profiles can not have config clashes. Configuration that // has the same name as a module's configuration will be used instead. - if (!$this->profileHandler->isProfile($name)) { + $profiles = $this->profileHandler->getProfileDependencies(); + if (!isset($profiles[$name])) { // Throw an exception if the module being installed contains configuration // that already exists. Additionally, can not continue installing more // modules because those may depend on the current module being installed. diff -u b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php --- b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -122,7 +122,7 @@ $profile_list = $listing->scan('profile'); } $profile_names = \Drupal::service('profile_handler')->getProfileDependencies($profile); - foreach ($profile_names as $profile_name) { + foreach ($profile_names as $profile_name => $profile_path) { if (isset($profile_list[$profile_name])) { $profile_folders = $this->getComponentNames(array($profile_list[$profile_name])); $this->folders = $profile_folders + $this->folders; diff -u b/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php --- b/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -164,8 +164,8 @@ drupal_get_filename('profile', $profile_name, $profile_object->getPathname()); } // Now that we can fetch the path, get dependent profiles and add the extensions - $profile_names = \Drupal::service('profile_handler')->getProfileDependencies(drupal_get_profile()); - foreach ($profile_names as $profile_name) { + $profile_names = \Drupal::service('profile_handler')->getProfileDependencies(); + foreach ($profile_names as $profile_name => $profile_path) { $this->folders += $this->getComponentNames(array($profiles[$profile_name])); } // @todo Remove as part of https://www.drupal.org/node/2186491 diff -u b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php --- b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -249,9 +249,11 @@ // In case both profile directories contain the same extension, the actual // profile always has precedence. if ($profile) { + // ExtensionDiscovery can be called without a service container. + // (@drupalKernel::moduleData) so check if profile_handler is available. if (\Drupal::hasService('profile_handler')) { $profile_handler = \Drupal::service('profile_handler'); - $this->profileDirectories = array_merge($profile_handler->getProfileDirectories($profile), $this->profileDirectories); + $this->profileDirectories = array_merge($profile_handler->getProfileDependencies($profile), $this->profileDirectories); } else { $this->profileDirectories[] = drupal_get_path('profile', $profile); 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 @@ -36,14 +36,18 @@ /** * {@inheritdoc} */ - public function getProfileDependencies($profile) { + public function getProfileDependencies($profile = NULL) { + if (empty($profile)) { + $profile = drupal_get_profile(); + } if (!isset(static::$cache[$profile])) { $profiles = array(); // Check if a valid profile name was given. if (!empty($profile)) { // We can't use install_profile_info() because that could trigger an // endless loop. So we read this on our own. - $profile_file = drupal_get_path('profile', $profile) . "/$profile.info.yml"; + $profile_path = drupal_get_path('profile', $profile); + $profile_file = $profile_path . "/$profile.info.yml"; $profile_info = $this->infoParser->parse($profile_file); // Check of the profile has a base profile and if so add it - recursion. @@ -55,29 +59,9 @@ // Add requested profile as last one. - $profiles[$profile] = $profile; + $profiles[$profile] = $profile_path; } static::$cache[$profile] = $profiles; } return static::$cache[$profile]; } - /** - * {@inheritdoc} - */ - public function getProfileDirectories($profile) { - $profile_directories = array(); - foreach ($this->getProfileDependencies($profile) as $profile_dependency => $profile_dependency_info) { - $profile_directories[] = drupal_get_path('profile', $profile_dependency); - } - return $profile_directories; - } - - /** - * {@inheritdoc} - */ - public function isProfile($profile) { - $current_profile = drupal_get_profile(); - $base_profiles = $this->getProfileDependencies($current_profile); - return isset($base_profiles[$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 @@ -12,34 +12,12 @@ * * @param string $profile - * Name of profile. + * Name of profile. If none is specified, use the current profile. * * @return array - * List of dependent installation profiles in descending order of their - * dependencies. + * List of dependent installation profiles paths keys by profile name + * in descending order of their dependencies. + * (parent profiles first, main profile last) */ - public function getProfileDependencies($profile); - - /** - * Returns an array of install profile directories - * - * @param string $profile - * Name of profile. - * - * @return array - * List of profile paths - */ - public function getProfileDirectories($profile); - - /** - * Returns whether the given extension name is an install profile, - * including base profiles - * - * @param string $profile - * Name of profile. - * - * @return bool - * Returns true if $profile is an install profile or dependent profile - */ - public function isProfile($profile); + public function getProfileDependencies($profile = NULL); } 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 @@ -975,12 +975,7 @@ $modules = $listing->scan('module'); $profile = drupal_get_profile(); - if ($profile) { - $profile_names = \Drupal::service('profile_handler')->getProfileDependencies($profile); - } - else { - $profile_names = array_keys($profiles); - } + $profile_names = array_keys(\Drupal::service('profile_handler')->getProfileDependencies($profile)); // Include the installation profile in modules that are loaded. $weight = 1000; foreach ($profile_names as $profile_name) {