diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 95adc95..a0610ba 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -843,10 +843,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(); @@ -866,7 +867,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; } } @@ -888,6 +889,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; } diff --git a/core/includes/common.inc b/core/includes/common.inc index 0b95dcd..f75fcf9 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -5357,7 +5357,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/ 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 @@ -5365,17 +5364,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; diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 32ce838..427aef3 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -346,7 +346,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'); } /** @@ -623,7 +623,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; } @@ -651,7 +652,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'; @@ -1095,13 +1097,6 @@ function install_settings_form_submit($form, &$form_state) { } /** - * Finds all .profile files. - */ -function install_find_profiles() { - return file_scan_directory('./profiles', '/\.profile$/', array('key' => 'name')); -} - -/** * Installation task; select which profile to install. * * @param $install_state @@ -1127,7 +1122,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 { @@ -1145,41 +1140,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. @@ -1429,7 +1410,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']); @@ -1683,7 +1665,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']) { diff --git a/core/includes/install.inc b/core/includes/install.inc index d203db4..0b5fa2d 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -257,12 +257,11 @@ function drupal_rewrite_settings($settings = array()) { * 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()); @@ -671,15 +670,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()); @@ -796,7 +798,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'], diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php index c9baa83..f707a02 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php @@ -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/ diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/SystemListingTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/SystemListingTest.php index 48ef555..ad4266c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/SystemListingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/SystemListingTest.php @@ -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', ), ); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a76e3ae..247af62 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2622,11 +2622,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; diff --git a/profiles/minimal/minimal.info b/core/profiles/minimal/minimal.info similarity index 100% rename from profiles/minimal/minimal.info rename to core/profiles/minimal/minimal.info diff --git a/profiles/minimal/minimal.install b/core/profiles/minimal/minimal.install similarity index 100% rename from profiles/minimal/minimal.install rename to core/profiles/minimal/minimal.install diff --git a/profiles/minimal/minimal.profile b/core/profiles/minimal/minimal.profile similarity index 100% rename from profiles/minimal/minimal.profile rename to core/profiles/minimal/minimal.profile diff --git a/profiles/minimal/translations/README.txt b/core/profiles/minimal/translations/README.txt similarity index 100% rename from profiles/minimal/translations/README.txt rename to core/profiles/minimal/translations/README.txt diff --git a/profiles/standard/standard.info b/core/profiles/standard/standard.info similarity index 100% rename from profiles/standard/standard.info rename to core/profiles/standard/standard.info diff --git a/profiles/standard/standard.install b/core/profiles/standard/standard.install similarity index 100% rename from profiles/standard/standard.install rename to core/profiles/standard/standard.install diff --git a/profiles/standard/standard.profile b/core/profiles/standard/standard.profile similarity index 100% rename from profiles/standard/standard.profile rename to core/profiles/standard/standard.profile diff --git a/profiles/standard/translations/README.txt b/core/profiles/standard/translations/README.txt similarity index 100% rename from profiles/standard/translations/README.txt rename to core/profiles/standard/translations/README.txt diff --git a/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info b/core/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info similarity index 100% rename from profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info rename to core/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info diff --git a/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module b/core/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module similarity index 100% rename from profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module rename to core/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module diff --git a/profiles/testing/modules/drupal_system_listing_compatible_test/lib/Drupal/drupal_system_listing_compatible_test/Tests/SystemListingCompatibleTest.php b/core/profiles/testing/modules/drupal_system_listing_compatible_test/lib/Drupal/drupal_system_listing_compatible_test/Tests/SystemListingCompatibleTest.php similarity index 100% rename from profiles/testing/modules/drupal_system_listing_compatible_test/lib/Drupal/drupal_system_listing_compatible_test/Tests/SystemListingCompatibleTest.php rename to core/profiles/testing/modules/drupal_system_listing_compatible_test/lib/Drupal/drupal_system_listing_compatible_test/Tests/SystemListingCompatibleTest.php diff --git a/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info b/core/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info similarity index 100% rename from profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info rename to core/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info diff --git a/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module b/core/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module similarity index 100% rename from profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module rename to core/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module diff --git a/profiles/testing/testing.info b/core/profiles/testing/testing.info similarity index 100% rename from profiles/testing/testing.info rename to core/profiles/testing/testing.info diff --git a/profiles/testing/testing.install b/core/profiles/testing/testing.install similarity index 100% rename from profiles/testing/testing.install rename to core/profiles/testing/testing.install diff --git a/profiles/testing/testing.profile b/core/profiles/testing/testing.profile similarity index 100% rename from profiles/testing/testing.profile rename to core/profiles/testing/testing.profile diff --git a/sites/all/README.txt b/sites/all/README.txt index c897088..d25add3 100644 --- a/sites/all/README.txt +++ b/sites/all/README.txt @@ -1,7 +1,7 @@ -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. diff --git a/sites/all/profiles/README.txt b/sites/all/profiles/README.txt new file mode 100644 index 0000000..2bbf4c9 --- /dev/null +++ b/sites/all/profiles/README.txt @@ -0,0 +1,4 @@ + +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.