Commit b996bbb2 authored by catch's avatar catch

Issue #562042 by cburschka, Rob Loach, sun, scor: Added Search for install...

Issue #562042 by cburschka, Rob Loach, sun, scor: Added Search for install profiles in sites/[all|site]/profiles folders, and move core profiles into /core/profiles.
parent 7e9d2c16
......@@ -847,10 +847,11 @@ function drupal_get_filename($type, $name, $filename = NULL) {
// drupal_static().
static $files = array(), $dirs = array();
// Profiles are a special case: they have a fixed location and naming.
// Profiles are converted into modules in system_rebuild_module_data().
// @todo Remove false-exposure of profiles as modules.
$original_type = $type;
if ($type == 'profile') {
$profile_filename = "profiles/$name/$name.profile";
$files[$type][$name] = file_exists($profile_filename) ? $profile_filename : FALSE;
$type = 'module';
}
if (!isset($files[$type])) {
$files[$type] = array();
......@@ -870,7 +871,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
try {
if (function_exists('db_query')) {
$file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
if (file_exists(DRUPAL_ROOT . '/' . $file)) {
if ($file && file_exists(DRUPAL_ROOT . '/' . $file)) {
$files[$type][$name] = $file;
}
}
......@@ -892,6 +893,12 @@ function drupal_get_filename($type, $name, $filename = NULL) {
elseif ($type == 'theme') {
$extension = 'info';
}
// Profiles are converted into modules in system_rebuild_module_data().
// @todo Remove false-exposure of profiles as modules.
elseif ($original_type == 'profile') {
$dir = 'profiles';
$extension = 'profile';
}
else {
$extension = $type;
}
......
......@@ -5168,7 +5168,6 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
// themes as provided by a distribution. It is pristine in the same way that
// the 'core/modules' directory is pristine for core; users should avoid
// any modification by using the sites/all or sites/<domain> directories.
$profiles = array();
$profile = drupal_get_profile();
// For SimpleTest to be able to test modules packaged together with a
// distribution we need to include the profile of the parent site (in which
......@@ -5176,17 +5175,16 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
if (drupal_valid_test_ua()) {
$testing_profile = variable_get('simpletest_parent_profile', FALSE);
if ($testing_profile && $testing_profile != $profile) {
$profiles[] = $testing_profile;
$searchdir[] = drupal_get_path('profile', $testing_profile) . '/' . $directory;
}
}
// In case both profile directories contain the same extension, the actual
// profile always has precedence.
$profiles[] = $profile;
foreach ($profiles as $profile) {
if (file_exists("profiles/$profile/$directory")) {
$searchdir[] = "profiles/$profile/$directory";
}
}
$searchdir[] = drupal_get_path('profile', $profile) . '/' . $directory;
// For the case of searching for profiles, scan top-level directories.
// @todo Replace entire sites/all/$directory with this.
$searchdir[] = $directory;
// Always search sites/all/* as well as the global directories.
$searchdir[] = 'sites/all/' . $directory;
......
......@@ -342,7 +342,7 @@ function install_begin_request(&$install_state) {
$install_state['database_tables_exist'] = !empty($task);
// Add the list of available profiles to the installation state.
$install_state['profiles'] += install_find_profiles();
$install_state['profiles'] += drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.profile$/', 'profiles');
}
/**
......@@ -619,7 +619,8 @@ function install_tasks($install_state) {
if (!empty($install_state['parameters']['profile'])) {
// Load the profile install file, because it is not always loaded when
// hook_install_tasks() is invoked (e.g. batch processing).
$profile_install_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.install';
$profile = $install_state['parameters']['profile'];
$profile_install_file = dirname($install_state['profiles'][$profile]->uri) . '/' . $profile . '.install';
if (file_exists($profile_install_file)) {
include_once $profile_install_file;
}
......@@ -647,7 +648,8 @@ function install_tasks($install_state) {
// Allow the installation profile to modify the full list of tasks.
if (!empty($install_state['parameters']['profile'])) {
$profile_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
$profile = $install_state['parameters']['profile'];
$profile_file = $install_state['profiles'][$profile]->uri;
if (file_exists($profile_file)) {
include_once $profile_file;
$function = $install_state['parameters']['profile'] . '_install_tasks_alter';
......@@ -1057,13 +1059,6 @@ function install_settings_form_submit($form, &$form_state) {
$install_state['completed_task'] = install_verify_completed_task();
}
/**
* Finds all .profile files.
*/
function install_find_profiles() {
return file_scan_directory('./profiles', '/\.profile$/', array('key' => 'name'));
}
/**
* Installation task; select which profile to install.
*
......@@ -1090,7 +1085,7 @@ function install_select_profile(&$install_state) {
if ($install_state['interactive']) {
include_once DRUPAL_ROOT . '/core/includes/form.inc';
drupal_set_title(st('Select an installation profile'));
$form = drupal_get_form('install_select_profile_form', $install_state['profiles']);
$form = drupal_get_form('install_select_profile_form', $install_state);
return drupal_render($form);
}
else {
......@@ -1108,41 +1103,27 @@ function install_select_profile(&$install_state) {
* list or from a selection passed in via $_POST.
*/
function _install_select_profile($profiles) {
if (sizeof($profiles) == 0) {
throw new Exception(install_no_profile_error());
}
// Don't need to choose profile if only one available.
if (sizeof($profiles) == 1) {
if (count($profiles) == 1) {
$profile = array_pop($profiles);
// TODO: is this right?
require_once DRUPAL_ROOT . '/' . $profile->uri;
return $profile->name;
}
else {
foreach ($profiles as $profile) {
if (!empty($_POST['profile']) && ($_POST['profile'] == $profile->name)) {
return $profile->name;
}
}
elseif (!empty($_POST['profile']) && isset($profiles[$_POST['profile']])) {
return $profiles[$_POST['profile']]->name;
}
}
/**
* Form API array definition for the profile selection form.
*
* @param $form_state
* Array of metadata about state of form processing.
* @param $profile_files
* Array of .profile files, as returned from file_scan_directory().
* @param array $install_state
* An array of information about the current installation state.
*/
function install_select_profile_form($form, &$form_state, $profile_files) {
function install_select_profile_form($form, &$form_state, $install_state) {
$profiles = array();
$names = array();
foreach ($profile_files as $profile) {
// TODO: is this right?
include_once DRUPAL_ROOT . '/' . $profile->uri;
foreach ($install_state['profiles'] as $profile) {
$details = install_profile_info($profile->name);
// Don't show hidden profiles. This is used by to hide the testing profile,
// which only exists to speed up test runs.
......@@ -1392,7 +1373,8 @@ function install_already_done_error() {
* the profile cannot be loaded.
*/
function install_load_profile(&$install_state) {
$profile_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
$profile = $install_state['parameters']['profile'];
$profile_file = $install_state['profiles'][$profile]->uri;
if (file_exists($profile_file)) {
include_once $profile_file;
$install_state['profile_info'] = install_profile_info($install_state['parameters']['profile'], $install_state['parameters']['langcode']);
......@@ -1652,7 +1634,7 @@ function install_check_requirements($install_state) {
$profile = $install_state['parameters']['profile'];
// Check the profile requirements.
$requirements = drupal_check_profile($profile);
$requirements = drupal_check_profile($profile, $install_state);
// If Drupal is not set up already, we need to create a settings file.
if (!$install_state['settings_verified']) {
......
......@@ -309,12 +309,11 @@ function install_ensure_config_directory() {
* The list of modules to install.
*/
function drupal_verify_profile($install_state) {
$profile = $install_state['parameters']['profile'];
include_once DRUPAL_ROOT . '/core/includes/file.inc';
include_once DRUPAL_ROOT . '/core/includes/common.inc';
$profile_file = DRUPAL_ROOT . "/profiles/$profile/$profile.profile";
$profile = $install_state['parameters']['profile'];
$profile_file = $install_state['profiles'][$profile]->uri;
if (!isset($profile) || !file_exists($profile_file)) {
throw new Exception(install_no_profile_error());
......@@ -729,15 +728,18 @@ function st($string, array $args = array(), array $options = array()) {
/**
* Check an install profile's requirements.
*
* @param $profile
* @param string $profile
* Name of install profile to check.
* @return
* @param array $install_state
* The current state in the install process.
*
* @return array
* Array of the install profile's requirements.
*/
function drupal_check_profile($profile) {
function drupal_check_profile($profile, array $install_state) {
include_once DRUPAL_ROOT . '/core/includes/file.inc';
$profile_file = DRUPAL_ROOT . "/profiles/$profile/$profile.profile";
$profile_file = $install_state['profiles'][$profile]->uri;
if (!isset($profile) || !file_exists($profile_file)) {
throw new Exception(install_no_profile_error());
......@@ -854,7 +856,9 @@ function install_profile_info($profile, $langcode = 'en') {
'hidden' => FALSE,
'php' => DRUPAL_MINIMUM_PHP,
);
$info = drupal_parse_info_file("profiles/$profile/$profile.info") + $defaults;
$profile_file = drupal_get_path('profile', $profile) . "/$profile.info";
$info = drupal_parse_info_file($profile_file);
$info += $defaults;
$info['dependencies'] = array_unique(array_merge(
drupal_required_modules(),
$info['dependencies'],
......
......@@ -41,7 +41,7 @@ function testDrupalGetFilename() {
// Retrieving the location of a profile. Profiles are a special case with
// a fixed location and naming.
$this->assertIdentical(drupal_get_filename('profile', 'standard'), 'profiles/standard/standard.profile', t('Retrieve install profile location.'));
$this->assertIdentical(drupal_get_filename('profile', 'standard'), 'core/profiles/standard/standard.profile', t('Retrieve install profile location.'));
// When a file is not found in the database cache, drupal_get_filename()
// searches several locations on the filesystem, including the core/
......
......@@ -33,12 +33,12 @@ function testDirectoryPrecedence() {
// precedence.
'drupal_system_listing_incompatible_test' => array(
'core/modules/system/tests/modules',
'profiles/testing/modules',
'core/profiles/testing/modules',
),
// When both copies of the module are compatible with Drupal core, the
// copy in the profile directory takes precedence.
'drupal_system_listing_compatible_test' => array(
'profiles/testing/modules',
'core/profiles/testing/modules',
'core/modules/system/tests/modules',
),
);
......
......@@ -2648,11 +2648,12 @@ function _system_rebuild_module_data() {
// Find modules
$modules = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0);
// Find installation profiles.
$profiles = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.profile$/', 'profiles', 'name', 0);
// Include the install profile in modules that are loaded.
$profile = drupal_get_profile();
$modules[$profile] = new stdClass();
$modules[$profile]->name = $profile;
$modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile';
$modules[$profile] = $profiles[$profile];
// Install profile hooks are always executed last.
$modules[$profile]->weight = 1000;
......
This directory should be used to place downloaded and custom modules
and themes which are common to all sites. Keeping contributed and
custom modules and themes in the sites directory will aid in upgrading
Drupal core files. Place contributed and custom modules and themes in
the sites/all/modules and sites/all/themes directories respectively.
This directory should be used to place downloaded and custom modules, themes
and profiles which are common to all sites. Keeping contributed and custom
modules, themes, and profiles in the sites directory will aid in upgrading
Drupal core files. Place contributed and custom modules, themes, and profiles
in the sites/all/modules, sites/all/themes, and sites/all/profiles directories
respectively.
This directory should be used to place downloaded and custom profiles
which are common to all sites. This will allow you to more easily
update Drupal core files.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment