diff --git includes/bootstrap.inc includes/bootstrap.inc index 4cbfc3f..fce29e8 100644 --- includes/bootstrap.inc +++ includes/bootstrap.inc @@ -773,6 +773,98 @@ function variable_initialize($conf = array()) { } /** + * Get the name of the currently active install profile. + * + * When this function is called during Drupal's initial installation process, + * the name of the profile that's about to be installed is stored in the global + * installation state. At all other times, the standard Drupal systems variable + * table contains the name of the current profile, and we can call variable_get() + * to determine what one is active. + * + * @return $profile + * The name of the install profile. + */ +function drupal_get_profile() { + global $install_state; + + if (isset($install_state['parameters']['profile'])) { + $profile = $install_state['parameters']['profile']; + } + else { + $profile = variable_get('install_profile', 'standard'); + } + + return $profile; +} + +/** + * Add directories to search for system object files (modules, themes, etc.). + * + * This function is used to add directories to be searched when we build + * the system table. Modules found in these locations will override objects in + * the /modules/ and /profiles/your_site_profile/modules/ directories, + * but modules in the /sites/all/modules/ and /sites/your_site_dir/modules/ + * directories will take precedence over them. + * + * @param $scope + * The directory type to be added. May be one of the following: + * - host_profile + * @param $directory + * The path to be added. + */ +function drupal_add_system_directory($scope = null, $directory = null) { + static $search_dirs = array(); + + // Pre-load the directory array with the know directory scopes. + if (!sizeof($search_dirs)) { + // The 'profiles' directory contains pristine collections of modules and + // themes as organized by a distribution. It is pristine in the same way + // that /modules is pristine for core; users should avoid changing anything + // there in favor of sites/all or sites/ directories. + $search_dirs['profile'] = "profiles/standard"; + + // The active install profile directory for the host site from within a test. + // If no test is active no host profile directory will be set. + $search_dirs['host_profile'] = NULL; + + // Always search sites/all/* as well as the global directories + $search_dirs['sites_all'] = 'sites/all'; + + // The configuraton path. + $search_dirs['settings'] = NULL; + } + + // Return the entire list of directories. + if (is_null($scope) && is_null($directory)) { + return $search_dirs; + } + + if (!is_null($directory) && !is_null($scope)) { + $search_dirs[$scope] = $directory; + } + + if (array_key_exists($scope, $search_dirs)) { + return $search_dirs[$scope]; + } + + return FALSE; +} + +/** + * Returns directories searched for system object files (modules, themes etc.). + * + * This function is used to return the directories that have been added with + * drupal_add_system_directory(). + * + * @return + * Array containing directory paths. + */ +function drupal_get_system_directory() { + return drupal_add_system_directory(); +} + + +/** * Returns a persistent variable. * * Case-sensitivity of the variable_* functions depends on the database @@ -2089,6 +2181,10 @@ function _drupal_bootstrap_configuration() { timer_start('page'); // Initialize the configuration, including variables from settings.php. drupal_settings_initialize(); + + // Add the config path to the search path. + drupal_add_system_directory('settings', conf_path()); + } /** @@ -2220,6 +2316,10 @@ function _drupal_bootstrap_variables() { // Load variables from the database, but do not overwrite variables set in settings.php. $conf = variable_initialize(isset($conf) ? $conf : array()); + + // Add the installation profile to the system directories. + drupal_add_system_directory('profile', "profiles/" . drupal_get_profile()); + // Load bootstrap modules. require_once DRUPAL_ROOT . '/includes/module.inc'; module_load_all(TRUE); diff --git includes/common.inc includes/common.inc index 5a7e340..9e6d970 100644 --- includes/common.inc +++ includes/common.inc @@ -195,32 +195,6 @@ function drupal_get_region_content($region = NULL, $delimiter = ' ') { } /** - * Get the name of the currently active install profile. - * - * When this function is called during Drupal's initial installation process, - * the name of the profile that's about to be installed is stored in the global - * installation state. At all other times, the standard Drupal systems variable - * table contains the name of the current profile, and we can call variable_get() - * to determine what one is active. - * - * @return $profile - * The name of the install profile. - */ -function drupal_get_profile() { - global $install_state; - - if (isset($install_state['parameters']['profile'])) { - $profile = $install_state['parameters']['profile']; - } - else { - $profile = variable_get('install_profile', 'standard'); - } - - return $profile; -} - - -/** * Set the breadcrumb trail for the current page. * * @param $breadcrumb @@ -4755,6 +4729,7 @@ function drupal_cron_cleanup() { } } + /** * Returns information about system object files (modules, themes, etc.). * @@ -4805,24 +4780,15 @@ function drupal_cron_cleanup() { function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) { $config = conf_path(); - $profile = drupal_get_profile(); $searchdir = array($directory); $files = array(); - // The 'profiles' directory contains pristine collections of modules and - // themes as organized by a distribution. It is pristine in the same way - // that /modules is pristine for core; users should avoid changing anything - // there in favor of sites/all or sites/ directories. - if (file_exists("profiles/$profile/$directory")) { - $searchdir[] = "profiles/$profile/$directory"; - } - - // Always search sites/all/* as well as the global directories - $searchdir[] = 'sites/all/' . $directory; - - if (file_exists("$config/$directory")) { - $searchdir[] = "$config/$directory"; + // Include directories from the drupal_add_system_directory() function. + foreach (drupal_get_system_directory() as $search) { + if (!is_null($search) && file_exists("$search/$directory")) { + $searchdir[] = "$search/$directory"; + } } // Get current list of items diff --git includes/install.core.inc includes/install.core.inc index 3b39e08..6c5a5db 100644 --- includes/install.core.inc +++ includes/install.core.inc @@ -572,6 +572,8 @@ function install_tasks($install_state) { // Now add any tasks defined by the installation profile. if (!empty($install_state['parameters']['profile'])) { + drupal_add_system_directory('profile', 'profiles/' . $install_state['parameters']['profile']); + $function = $install_state['parameters']['profile'] . '_install_tasks'; if (function_exists($function)) { $result = $function($install_state); diff --git modules/simpletest/drupal_web_test_case.php modules/simpletest/drupal_web_test_case.php index 257921a..5c604de 100644 --- modules/simpletest/drupal_web_test_case.php +++ modules/simpletest/drupal_web_test_case.php @@ -1192,6 +1192,11 @@ class DrupalWebTestCase extends DrupalTestCase { $this->originalProfile = drupal_get_profile(); $clean_url_original = variable_get('clean_url', 0); + // The host profile's collection of modules or themes need to be included + // when running tests that use an alternate install profile but still reside + // in the host profile's directory. + drupal_add_system_directory('host_profile', 'profiles/' . $this->originalProfile); + // Save and clean shutdown callbacks array because it static cached and // will be changed by the test run. If we don't, then it will contain // callbacks from both environments. So testing environment will try