Skip to content
Snippets Groups Projects
Commit 48e41d31 authored by Angie Byron's avatar Angie Byron
Browse files

#509392 follow-up by adrian: Clean-up for .info files for install profiles patch.

parent 3ccd4375
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -977,23 +977,49 @@ function drupal_check_module($module) {
/**
* Retrieve info about an install profile from its .info file.
*
* Information stored in the profile.info file:
* - name: The real name of the install profile for display purposes.
* - description: A brief description of the profile.
* - dependencies: An array of shortnames of other modules this install profile requires.
* - tasks: An associative array of tasks and the page title of each task that need to be
* completed for installation.
*
* Example of .info file:
* @verbatim
* name = Drupal (minimal)
* description = Create a Drupal site with only required modules enabled.
* dependencies[] = block
* dependencies[] = dblog
* @endverbatim
*
* @param profile
* Name of profile.
* @param locale
* Name of locale used (if any).
* @return
* The info array.
*/
function install_profile_info($profile, $locale = 'en') {
$cache =& drupal_static('install_profile_info', array(), TRUE);
// Set defaults for module info.
$defaults = array(
'dependencies' => array(),
'tasks' => array(),
'description' => '',
'version' => NULL,
'php' => DRUPAL_MINIMUM_PHP,
);
$info = drupal_parse_info_file(sprintf('profiles/%s/%s.info', $profile, $profile)) + $defaults;
$info['dependencies'] = array_unique(array_merge(
drupal_required_modules(),
$info['dependencies'],
($locale != 'en' && !empty($locale) ? array('locale') : array()))
);
return $info;
$cache = &drupal_static(__FUNCTION__, array());
if (!isset($cache[$profile])) {
// Set defaults for module info.
$defaults = array(
'dependencies' => array(),
'tasks' => array(),
'description' => '',
'version' => NULL,
'php' => DRUPAL_MINIMUM_PHP,
);
$info = drupal_parse_info_file("profiles/$profile/$profile.info") + $defaults;
$info['dependencies'] = array_unique(array_merge(
drupal_required_modules(),
$info['dependencies'],
($locale != 'en' && !empty($locale) ? array('locale') : array()))
);
$cache[$profile] = $info;
}
return $cache[$profile];
}
......@@ -972,8 +972,10 @@ function install_task_list($active = NULL) {
// Add tasks defined by the profile.
if ($profile) {
$info = install_profile_info($profile);
if (array_key_exists('tasks', $info)) {
$tasks += $info['tasks'];
if (isset($info['tasks'])) {
foreach ($info['tasks'] as $task => $title) {
$tasks[$task] = st($title);
}
}
}
......
......@@ -23,7 +23,8 @@ class ModuleUnitTest extends DrupalWebTestCase {
*/
function testModuleList() {
// Build a list of modules, sorted alphabetically.
$module_list = drupal_get_profile_modules('default', 'en');
$profile_info = install_profile_info('default', 'en');
$module_list = $profile_info['dependencies'];
sort($module_list);
// Compare this list to the one returned by module_list(). We expect them
// to match, since all default profile modules have a weight equal to 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment