diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-10-23 06:45:17 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-10-23 06:45:17 +0000 |
commit | af5402ad2abd530a192115a2760cf00fe0d151f3 (patch) | |
tree | 43cb2487da80ebf0617d7a133392c3b55c069c94 | |
parent | 8ab113e7530c969a867488ee9d9faa8d3fb68a15 (diff) | |
download | brdo-af5402ad2abd530a192115a2760cf00fe0d151f3.tar.gz brdo-af5402ad2abd530a192115a2760cf00fe0d151f3.tar.bz2 |
- Patch #88287 by asimmonds, dww et al: installer doesn't support modules outside root/modules directory. Critical bugfix.
-rw-r--r-- | includes/common.inc | 63 | ||||
-rw-r--r-- | includes/install.inc | 22 | ||||
-rw-r--r-- | includes/module.inc | 2 | ||||
-rw-r--r-- | modules/system/system.module | 60 | ||||
-rw-r--r-- | themes/engines/phptemplate/phptemplate.engine | 2 |
5 files changed, 83 insertions, 66 deletions
diff --git a/includes/common.inc b/includes/common.inc index 9104a78f9..b0b184ee4 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1754,6 +1754,69 @@ function drupal_cron_cleanup() { } /** + * Returns an array of files objects of the given type from the site-wide + * directory (i.e. modules/), the all-sites directory (i.e. + * sites/all/modules/), the profiles directory, and site-specific directory + * (i.e. sites/somesite/modules/). The returned array will be keyed using the + * key specified (name, basename, filename). Using name or basename will cause + * site-specific files to be prioritized over similar files in the default + * directories. That is, if a file with the same name appears in both the + * site-wide directory and site-specific directory, only the site-specific + * version will be included. + * + * @param $mask + * The regular expression of the files to find. + * @param $directory + * The subdirectory name in which the files are found. For example, + * 'modules' will search in both modules/ and + * sites/somesite/modules/. + * @param $key + * The key to be passed to file_scan_directory(). + * @param $min_depth + * Minimum depth of directories to return files from. + * + * @return + * An array of file objects of the specified type. + */ +function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) { + global $profile; + $config = conf_path(); + + // 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 + // $profile variable. 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. + if (!isset($profile)) { + $profile = variable_get('install_profile', 'default'); + } + $searchdir = array($directory); + $files = array(); + + // Always search sites/all/* as well as the global directories + $searchdir[] = 'sites/all'; + + // 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/<domain> directories. + if (file_exists("profiles/$profile/$directory")) { + $searchdir[] = "profiles/$profile/$directory"; + } + + if (file_exists("$config/$directory")) { + $searchdir[] = "$config/$directory"; + } + + // Get current list of items + foreach ($searchdir as $dir) { + $files = array_merge($files, file_scan_directory($dir, $mask, array('.', '..', 'CVS'), 0, TRUE, $key, $min_depth)); + } + + return $files; +} + +/** * Renders HTML given a structured array tree. Recursively iterates over each * of the array elements, generating HTML code. This function is usually * called from within a another function, like drupal_get_form() or node_view(). diff --git a/includes/install.inc b/includes/install.inc index 2aa93767e..4c7ed74d2 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -259,6 +259,7 @@ function drupal_get_install_files($module_list = array()) { */ function drupal_verify_profile($profile, $locale) { include_once './includes/file.inc'; + include_once './includes/common.inc'; $profile_file = "./profiles/$profile/$profile.profile"; @@ -272,17 +273,22 @@ function drupal_verify_profile($profile, $locale) { $function = $profile .'_profile_modules'; $module_list = array_merge(array('system'), $function(), ($locale ? array('locale') : array())); - // Verify that all required modules exist. - $modules_present = TRUE; - foreach ($module_list as $module) { - $module_path = dirname(drupal_get_filename('module', $module, NULL, FALSE)); - if (!$module_path) { + // Get a list of modules that exist in Drupal's assorted subdirectories. + $present_modules = array(); + foreach(drupal_system_listing('\.module$', 'modules', 'name', 0) as $present_module) { + $present_modules[] = $present_module->name; + } + + // Verify that all of the profile's required modules are present. + $missing_modules = array_diff($module_list, $present_modules); + if (count($missing_modules)) { + foreach($missing_modules as $module) { drupal_set_message(st('The %module module is required but was not found. Please move it into the <em>modules</em> subdirectory.', array('%module' => $module)), 'error'); - $modules_present = FALSE; } } - - return $modules_present ? $module_list : NULL; + else { + return $module_list; + } } /** diff --git a/includes/module.inc b/includes/module.inc index 3a5b2b666..6bbeb2a41 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -95,7 +95,7 @@ function module_list($refresh = FALSE, $bootstrap = TRUE, $sort = FALSE, $fixed_ */ function module_rebuild_cache() { // Get current list of modules - $files = system_listing('\.module$', 'modules', 'name', 0); + $files = drupal_system_listing('\.module$', 'modules', 'name', 0); // Extract current files from database. system_get_files_database($files, 'module'); diff --git a/modules/system/system.module b/modules/system/system.module index bb9161718..b2a8761d1 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -869,11 +869,13 @@ function system_get_files_database(&$files, $type) { * Collect data about all currently available themes */ function system_theme_data() { + include_once './includes/install.inc'; + // Find themes - $themes = system_listing('\.theme$', 'themes'); + $themes = drupal_system_listing('\.theme$', 'themes'); // Find theme engines - $engines = system_listing('\.engine$', 'themes/engines'); + $engines = drupal_system_listing('\.engine$', 'themes/engines'); // can't iterate over array itself as it uses a copy of the array items foreach (array_keys($themes) as $key) { @@ -997,60 +999,6 @@ function system_default_region($theme) { } /** - * Returns an array of files objects of the given type from the site-wide - * directory (i.e. modules/), the all-sites directory (i.e. - * sites/all/modules/), the profiles directory, and site-specific directory - * (i.e. sites/somesite/modules/). The returned array will be keyed using the - * key specified (name, basename, filename). Using name or basename will cause - * site-specific files to be prioritized over similar files in the default - * directories. That is, if a file with the same name appears in both the - * site-wide directory and site-specific directory, only the site-specific - * version will be included. - * - * @param $mask - * The regular expression of the files to find. - * @param $directory - * The subdirectory name in which the files are found. For example, - * 'modules' will search in both modules/ and - * sites/somesite/modules/. - * @param $key - * The key to be passed to file_scan_directory(). - * @param $min_depth - * Minimum depth of directories to return files from. - * - * @return - * An array of file objects of the specified type. - */ -function system_listing($mask, $directory, $key = 'name', $min_depth = 1) { - $config = conf_path(); - $profile = variable_get('install_profile', 'default'); - $searchdir = array($directory); - $files = array(); - - // Always search sites/all/* as well as the global directories - $searchdir[] = 'sites/all'; - - // 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/<domain> directories. - if (file_exists("profiles/$profile/$directory")) { - $searchdir[] = "profiles/$profile/$directory"; - } - - if (file_exists("$config/$directory")) { - $searchdir[] = "$config/$directory"; - } - - // Get current list of items - foreach ($searchdir as $dir) { - $files = array_merge($files, file_scan_directory($dir, $mask, array('.', '..', 'CVS'), 0, TRUE, $key, $min_depth)); - } - - return $files; -} - -/** * Assign an initial, default set of blocks for a theme. * * This function is called the first time a new theme is enabled. The new theme diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine index b6504d06a..b3d8843ef 100644 --- a/themes/engines/phptemplate/phptemplate.engine +++ b/themes/engines/phptemplate/phptemplate.engine @@ -14,7 +14,7 @@ function phptemplate_init($template) { } function phptemplate_templates($directory = 'themes') { - return system_listing('^page\.tpl\.php$', $directory, 'filename'); + return drupal_system_listing('^page\.tpl\.php$', $directory, 'filename'); } /** |