diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index a90529494f..39f15149a3 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1268,10 +1268,13 @@ function install_select_profile(&$install_state) { } /** - * Determines whether or not to automatically install a profile by default. + * Determines the installation profile to use in the installer. * - * Under certain conditions (listed below), a default profile will be selected - * (and subsequently installed) without allowing the user to choose a profile. + * Depending on the context from which it's being called, this method + * may be used to: + * - Automatically select a profile under certain conditions. + * - Indicate which profile has already been selected. + * - Indicate that a profile still needs to be selected. * * A profile will be selected in the following order of conditions: * - Only one profile is available. @@ -1282,8 +1285,7 @@ function install_select_profile(&$install_state) { * distributions, then the first discovered profile will be selected. * - Only one visible profile is available. * - * If NULL is returned (a profile has not been selected), then the interactive - * installer will allow the selection of one of the visible profiles. + * If none of the above conditions are met, then this method will return NULL. * * @param array $install_state * The current installer state, containing a 'profiles' key, which is an @@ -1292,32 +1294,34 @@ function install_select_profile(&$install_state) { * @return string|null * The machine-readable name of the selected profile or NULL if no profile was * selected. + * + * @see install_select_profile() */ function _install_select_profile(&$install_state) { - // Don't need to choose profile if only one available. + // If there is only one profile available it will always be the one selected. if (count($install_state['profiles']) == 1) { return key($install_state['profiles']); } + // If a valid profile has already been selected, return the selection. if (!empty($install_state['parameters']['profile'])) { $profile = $install_state['parameters']['profile']; if (isset($install_state['profiles'][$profile])) { return $profile; } } - // Check for a distribution profile. + // If any of the profiles are distribution profiles, return the first one. foreach ($install_state['profiles'] as $profile) { $profile_info = install_profile_info($profile->getName()); if (!empty($profile_info['distribution'])) { return $profile->getName(); } } - // Get all visible (not hidden) profiles. $visible_profiles = array_filter($install_state['profiles'], function ($profile) { $profile_info = install_profile_info($profile->getName()); return !isset($profile_info['hidden']) || !$profile_info['hidden']; }); - + // If there is only one visible profile, return it. if (count($visible_profiles) == 1) { return (key($visible_profiles)); }