? 147000.patch ? sites/drupal-head ? sites/all/modules Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.128 diff -u -p -r1.128 install.php --- install.php 6 Sep 2008 08:36:19 -0000 1.128 +++ install.php 7 Sep 2008 19:01:19 -0000 @@ -618,7 +618,7 @@ function install_tasks($profile, $task) // Bootstrap newly installed Drupal, while preserving existing messages. $messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : ''; drupal_install_init_database(); - + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $_SESSION['messages'] = $messages; @@ -637,7 +637,7 @@ function install_tasks($profile, $task) // Install profile modules. if ($task == 'profile-install') { $modules = variable_get('install_profile_modules', array()); - $files = module_rebuild_cache(); + $files = system_get_module_data(); variable_del('install_profile_modules'); $operations = array(); foreach ($modules as $module) { @@ -1179,4 +1179,3 @@ function install_configure_form_submit($ // Start the installer. install_main(); - Index: update.php =================================================================== RCS file: /cvs/drupal/drupal/update.php,v retrieving revision 1.256 diff -u -p -r1.256 update.php --- update.php 31 Aug 2008 12:45:41 -0000 1.256 +++ update.php 7 Sep 2008 19:01:20 -0000 @@ -479,8 +479,8 @@ function update_check_incompatibility($n // Store values of expensive functions for future use. if (empty($themes) || empty($modules)) { - $themes = system_theme_data(); - $modules = module_rebuild_cache(); + $themes = system_get_theme_data(); + $modules = system_get_module_data(); } if ($type == 'module' && isset($modules[$name])) { Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.790 diff -u -p -r1.790 common.inc --- includes/common.inc 6 Sep 2008 15:06:10 -0000 1.790 +++ includes/common.inc 7 Sep 2008 19:01:37 -0000 @@ -3531,7 +3531,7 @@ function drupal_flush_all_caches() { registry_rebuild(); drupal_clear_css_cache(); drupal_clear_js_cache(); - system_theme_data(); + system_get_theme_data(); drupal_theme_rebuild(); menu_rebuild(); node_types_rebuild(); Index: includes/install.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.inc,v retrieving revision 1.67 diff -u -p -r1.67 install.inc --- includes/install.inc 28 Aug 2008 08:40:33 -0000 1.67 +++ includes/install.inc 7 Sep 2008 19:01:42 -0000 @@ -88,7 +88,7 @@ function drupal_load_updates() { * @param $module * A module name. * @return - * If the module has updates, an array of available updates sorted by version. + * If the module has updates, an array of available updates sorted by version. * Otherwise, FALSE. */ function drupal_get_schema_versions($module) { @@ -105,10 +105,10 @@ function drupal_get_schema_versions($mod if (count($updates) == 0) { return FALSE; } - + // Make sure updates are run in numeric order, not in definition order. sort($updates, SORT_NUMERIC); - + return $updates; } @@ -233,7 +233,7 @@ function drupal_detect_database_types() unset($databases['mysql']); $databases = array('mysql' => $mysql_database) + $databases; } - + return $databases; } @@ -469,7 +469,7 @@ function drupal_verify_profile($profile, * The modules to install. */ function drupal_install_modules($module_list = array()) { - $files = module_rebuild_cache(); + $files = system_get_module_data(); $module_list = array_flip(array_values($module_list)); do { $moved = FALSE; @@ -516,7 +516,7 @@ function _drupal_install_module($module) */ function drupal_install_init_database() { static $included = FALSE; - + if (!$included) { $connection_info = Database::getConnectionInfo(); $driver = $connection_info['default']['driver']; @@ -540,14 +540,14 @@ function drupal_install_system() { require_once './' . $system_path . '/system.install'; drupal_install_init_database(); module_invoke('system', 'install'); - + $system_versions = drupal_get_schema_versions('system'); $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED; db_query("INSERT INTO {system} (filename, name, type, owner, status, bootstrap, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d, %d)", $system_path . '/system.module', 'system', 'module', '', 1, 0, $system_version); // Now that we've installed things properly, bootstrap the full Drupal environment drupal_install_init_database(); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - module_rebuild_cache(); + system_get_module_data(); } Index: includes/module.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/module.inc,v retrieving revision 1.124 diff -u -p -r1.124 module.inc --- includes/module.inc 21 Aug 2008 19:36:36 -0000 1.124 +++ includes/module.inc 7 Sep 2008 19:01:50 -0000 @@ -73,69 +73,6 @@ function module_list($refresh = FALSE, $ } /** - * Rebuild the database cache of module files. - * - * @return - * The array of filesystem objects used to rebuild the cache. - */ -function module_rebuild_cache() { - // Get current list of modules - $files = drupal_system_listing('\.module$', 'modules', 'name', 0); - - // Extract current files from database. - system_get_files_database($files, 'module'); - - ksort($files); - - // Set defaults for module info - $defaults = array( - 'dependencies' => array(), - 'dependents' => array(), - 'description' => '', - 'version' => NULL, - 'php' => DRUPAL_MINIMUM_PHP, - ); - - foreach ($files as $filename => $file) { - // Look for the info file. - $file->info = drupal_parse_info_file(dirname($file->filename) . '/' . $file->name . '.info'); - - // Skip modules that don't provide info. - if (empty($file->info)) { - unset($files[$filename]); - continue; - } - // Merge in defaults and save. - $files[$filename]->info = $file->info + $defaults; - - // Invoke hook_system_info_alter() to give installed modules a chance to - // modify the data in the .info files if necessary. - drupal_alter('system_info', $files[$filename]->info, $files[$filename]); - - // Log the critical hooks implemented by this module. - $bootstrap = 0; - foreach (bootstrap_hooks() as $hook) { - if (module_hook($file->name, $hook)) { - $bootstrap = 1; - break; - } - } - - // Update the contents of the system table: - if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) { - db_query("UPDATE {system} SET info = '%s', name = '%s', filename = '%s', bootstrap = %d WHERE filename = '%s'", serialize($files[$filename]->info), $file->name, $file->filename, $bootstrap, $file->old_filename); - } - else { - // This is a new module. - $files[$filename]->status = 0; - db_query("INSERT INTO {system} (name, info, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d)", $file->name, serialize($files[$filename]->info), 'module', $file->filename, 0, $bootstrap); - } - } - $files = _module_build_dependencies($files); - return $files; -} - -/** * Find dependencies any level deep and fill in dependents information too. * * If module A depends on B which in turn depends on C then this function will Index: includes/registry.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/registry.inc,v retrieving revision 1.3 diff -u -p -r1.3 registry.inc --- includes/registry.inc 21 Aug 2008 19:36:36 -0000 1.3 +++ includes/registry.inc 7 Sep 2008 19:02:08 -0000 @@ -41,7 +41,7 @@ function _registry_rebuild() { _registry_get_resource_name(); // Get the list of files we are going to parse. $files = array(); - foreach (module_rebuild_cache() as $module) { + foreach (system_get_module_data() as $module) { if ($module->status) { $dir = dirname($module->filename); foreach ($module->info['files'] as $file) { @@ -209,4 +209,3 @@ function _registry_skip_body(&$tokens) { /** * @} End of "defgroup registry". */ - Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.433 diff -u -p -r1.433 theme.inc --- includes/theme.inc 2 Sep 2008 17:38:55 -0000 1.433 +++ includes/theme.inc 7 Sep 2008 19:02:11 -0000 @@ -197,8 +197,8 @@ function _init_theme($theme, $base_theme /** * Get the theme registry. - * @return - * The theme registry array if it has been stored in memory, NULL otherwise. + * @return + * The theme registry array if it has been stored in memory, NULL otherwise. */ function theme_get_registry() { return _theme_set_registry(); @@ -208,16 +208,16 @@ function theme_get_registry() { * Store the theme registry in memory. * @param $registry * A registry array as returned by _theme_build_registry() - * @return + * @return * The theme registry array stored in memory */ function _theme_set_registry($registry = NULL) { static $theme_registry = NULL; - + if (isset($registry)) { $theme_registry = $registry; } - + return $theme_registry; } @@ -446,7 +446,7 @@ function list_themes($refresh = FALSE) { } else { // Scan the installation when the database should not be read. - $themes = _system_theme_data(); + $themes = _system_get_theme_data(); } foreach ($themes as $theme) { @@ -2001,4 +2001,3 @@ function template_preprocess_block(&$var $variables['template_files'][] = 'block-' . $variables['block']->module; $variables['template_files'][] = 'block-' . $variables['block']->module . '-' . $variables['block']->delta; } - Index: includes/theme.maintenance.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.maintenance.inc,v retrieving revision 1.16 diff -u -p -r1.16 theme.maintenance.inc --- includes/theme.maintenance.inc 21 Aug 2008 19:36:36 -0000 1.16 +++ includes/theme.maintenance.inc 7 Sep 2008 19:02:11 -0000 @@ -210,7 +210,7 @@ function template_preprocess_maintenance global $theme; // Retrieve the theme data to list all available regions. - $theme_data = _system_theme_data(); + $theme_data = _system_get_theme_data(); $regions = $theme_data[$theme]->info['regions']; // Get all region content set with drupal_set_content(). Index: modules/help/help.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/help/help.admin.inc,v retrieving revision 1.6 diff -u -p -r1.6 help.admin.inc --- modules/help/help.admin.inc 14 Apr 2008 17:48:37 -0000 1.6 +++ modules/help/help.admin.inc 7 Sep 2008 19:02:13 -0000 @@ -47,7 +47,7 @@ function help_page($name) { function help_links_as_list() { $empty_arg = drupal_help_arg(); - $module_info = module_rebuild_cache(); + $module_info = system_get_module_data(); $modules = array(); foreach (module_implements('help', TRUE) as $module) { @@ -73,4 +73,3 @@ function help_links_as_list() { return $output; } - Index: modules/simpletest/simpletest.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v retrieving revision 1.11 diff -u -p -r1.11 simpletest.module --- modules/simpletest/simpletest.module 21 Aug 2008 19:36:38 -0000 1.11 +++ modules/simpletest/simpletest.module 7 Sep 2008 19:02:19 -0000 @@ -413,7 +413,7 @@ function simpletest_get_all_tests() { if (!isset($formatted_classes)) { require_once drupal_get_path('module', 'simpletest') . '/drupal_web_test_case.php'; $files = array(); - foreach (array_keys(module_rebuild_cache()) as $module) { + foreach (array_keys(system_get_module_data()) as $module) { $module_path = drupal_get_path('module', $module); $test = $module_path . "/$module.test"; if (file_exists($test)) { Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.87 diff -u -p -r1.87 system.admin.inc --- modules/system/system.admin.inc 6 Sep 2008 08:36:21 -0000 1.87 +++ modules/system/system.admin.inc 7 Sep 2008 19:02:43 -0000 @@ -86,7 +86,7 @@ function system_admin_menu_block_page() */ function system_admin_by_module() { - $modules = module_rebuild_cache(); + $modules = system_get_module_data(); $menu_items = array(); $help_arg = module_exists('help') ? drupal_help_arg() : FALSE; @@ -139,7 +139,7 @@ function system_settings_overview() { * @see system_settings_form() */ function system_admin_theme_settings() { - $themes = system_theme_data(); + $themes = system_get_theme_data(); uasort($themes, 'system_sort_modules_by_info_name'); @@ -176,7 +176,7 @@ function system_admin_theme_settings() { function system_themes_form() { drupal_clear_css_cache(); - $themes = system_theme_data(); + $themes = system_get_theme_data(); uasort($themes, 'system_sort_modules_by_info_name'); @@ -320,7 +320,7 @@ function system_theme_settings(&$form_st if ($key) { $settings = theme_get_settings($key); $var = str_replace('/', '_', 'theme_' . $key . '_settings'); - $themes = system_theme_data(); + $themes = system_get_theme_data(); $features = $themes[$key]->info['features']; } else { @@ -612,7 +612,7 @@ function system_modules($form_state = ar menu_rebuild(); cache_clear_all('schema', 'cache'); // Get current list of modules. - $files = module_rebuild_cache(); + $files = system_get_module_data(); // Remove hidden modules from display list. foreach ($files as $filename => $file) { @@ -799,7 +799,7 @@ function _system_modules_build_row($info * Display confirmation form for dependencies. * * @param $modules - * Array of module file objects as returned from module_rebuild_cache(). + * Array of module file objects as returned from system_get_module_data(). * @param $storage * The contents of $form_state['storage']; an array with two * elements: the list of dependencies and the list of status @@ -856,7 +856,7 @@ function system_modules_submit($form, &$ } // Get a list of all modules, for building dependencies with. - $files = module_rebuild_cache(); + $files = system_get_module_data(); // The modules to be enabled. $enabled_modules = array(); Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.263 diff -u -p -r1.263 system.install --- modules/system/system.install 6 Sep 2008 08:36:21 -0000 1.263 +++ modules/system/system.install 7 Sep 2008 19:03:00 -0000 @@ -360,7 +360,7 @@ function system_install() { } // Load system theme data appropriately. - system_theme_data(); + system_get_theme_data(); // Inserting uid 0 here confuses MySQL -- the next user might be created as // uid 2 which is not what we want. So we insert the first user here, the @@ -1473,8 +1473,8 @@ function system_update_6008() { db_drop_field($ret, 'system', 'description'); // Rebuild system table contents. - module_rebuild_cache(); - system_theme_data(); + system_get_module_data(); + system_get_theme_data(); return $ret; } @@ -1545,8 +1545,8 @@ function system_update_6012() { */ function system_update_6013() { // Rebuild system table contents. - module_rebuild_cache(); - system_theme_data(); + system_get_module_data(); + system_get_theme_data(); return array(array('success' => TRUE, 'query' => 'Cache rebuilt.')); } @@ -3052,4 +3052,3 @@ function system_update_7010() { * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ - Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.617 diff -u -p -r1.617 system.module --- modules/system/system.module 6 Sep 2008 08:36:21 -0000 1.617 +++ modules/system/system.module 7 Sep 2008 19:03:11 -0000 @@ -900,89 +900,138 @@ function system_check_directory($form_el } /** - * Retrieves the current status of an array of files in the system table. + * Retrieves the current status of an array of files in the system table. The + * function also optionally compares and updates the system table based on the + * information provided in the $files parameter. * * @param $files * An array of files to check. * @param $type * The type of the files. + * @param $update + * A boolean flag to update system table records based on the $files array. */ -function system_get_files_database(&$files, $type) { - // Extract current files from database. - $result = db_query("SELECT filename, name, type, status, schema_version FROM {system} WHERE type = '%s'", $type); +function system_get_files_database(&$files, $type, $update = FALSE) { + // Make a copy of the files array to help keep track of which files aren't + // present in the system table and need to be added. + $files_new = $update ? $files : array(); + + $result = db_query("SELECT * FROM {system} WHERE type = '%s'", $type); while ($file = db_fetch_object($result)) { if (isset($files[$file->name]) && is_object($files[$file->name])) { - $file->old_filename = $file->filename; + + if ($update) { + $file->old_filename = $file->filename; + unset($files_new[$file->name]); + } + foreach ($file as $key => $value) { - if (!isset($files[$file->name]) || !isset($files[$file->name]->$key)) { + if (!isset($files[$file->name]->$key)) { $files[$file->name]->$key = $value; } + elseif ($update && $files[$file->name]->$key != $value) { + $files[$file->name]->updated = TRUE; + } + } + + if ($update && isset($files[$file->name]->updated)) { + db_update('system') + ->fields(array( + 'filename' => $files[$file->name]->filename, + 'name' => $files[$file->name]->name, + 'owner' => $files[$file->name]->owner, + 'bootstrap' => $files[$file->name]->bootstrap, + 'info' => serialize($files[$file->name]->info)) + ) + ->condition('filename', $files[$file->name]->old_filename) + ->execute(); + unset($files[$file->name]->updated); + unset($files[$file->name]->old_filename); } } + elseif (!isset($files[$file->name]) && $update) { + db_delete('system')->condition('filename', $file->filename)->execute(); + } + } + + if ($update) { + // New files, INSERT INTO SYSTEM TABLE + foreach($files_new as $file) { + db_insert('system') + ->fields(array( + 'filename' => $file->filename, + 'name' => $file->name, + 'type' => $type, + 'owner' => isset($file->owner) ? $file->owner : '', + 'bootstrap' => isset($file->bootstrap) ? $file->bootstrap : 0, + 'info' => serialize($file->info)) + ) + ->execute(); + } } } /** - * Prepare defaults for themes. + * Helper function to scan and collect module .info data. * * @return - * An array of default themes settings. + * An associative array of module information. */ -function system_theme_default() { - return array( - 'regions' => array( - 'left' => 'Left sidebar', - 'right' => 'Right sidebar', - 'content' => 'Content', - 'header' => 'Header', - 'footer' => 'Footer', - ), +function _system_get_module_data() { + // Find modules + $modules = drupal_system_listing('\.module$', 'modules', 'name', 0); + + // Set defaults for module info + $defaults = array( + 'dependencies' => array(), + 'dependents' => array(), 'description' => '', - 'features' => array( - 'comment_user_picture', - 'favicon', - 'mission', - 'logo', - 'name', - 'node_user_picture', - 'search', - 'slogan', - 'main_menu', - 'secondary_menu', - ), - 'stylesheets' => array( - 'all' => array('style.css') - ), - 'scripts' => array('script.js'), - 'screenshot' => 'screenshot.png', + 'version' => NULL, 'php' => DRUPAL_MINIMUM_PHP, ); -} - -/** - * Collect data about all currently available themes. - * - * @return - * Array of all available themes and their data. - */ -function system_theme_data() { - // Scan the installation theme .info files and their engines. - $themes = _system_theme_data(); - // Extract current files from database. - system_get_files_database($themes, 'theme'); + // Read info files for each theme + foreach ($modules as $key => $module) { + // Look for the info file. + $module->info = drupal_parse_info_file(dirname($module->filename) . '/' . $module->name . '.info'); + + // Skip modules that don't provide info. + if (empty($module->info)) { + unset($modules[$key]); + continue; + } - db_query("DELETE FROM {system} WHERE type = 'theme'"); + // Merge in defaults and save. + $modules[$key]->info = $module->info + $defaults; - foreach ($themes as $theme) { - if (!isset($theme->owner)) { - $theme->owner = ''; + // Invoke hook_system_info_alter() to give installed modules a chance to + // modify the data in the .info files if necessary. + drupal_alter('system_info', $modules[$key]->info, $modules[$key]); + + // Log the critical hooks implemented by this module. + $modules[$key]->bootstrap = 0; + foreach (bootstrap_hooks() as $hook) { + if (module_hook($modules[$key]->name, $hook)) { + $modules[$key]->bootstrap = 1; + break; + } } - - db_query("INSERT INTO {system} (name, owner, info, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0); } - return $themes; + return $modules; +} + +/** + * Collect data about all currently available modules. + * + * @return + * Array of all available modules and their data. + */ +function system_get_module_data() { + $modules = _system_get_module_data(); + system_get_files_database($modules, 'module', TRUE); + $modules = _module_build_dependencies($modules); + return $modules; } /** @@ -991,7 +1040,7 @@ function system_theme_data() { * @return * An associative array of themes information. */ -function _system_theme_data() { +function _system_get_theme_data() { static $themes_info = array(); if (empty($themes_info)) { @@ -1000,7 +1049,35 @@ function _system_theme_data() { // Find theme engines $engines = drupal_system_listing('\.engine$', 'themes/engines'); - $defaults = system_theme_default(); + // Set defaults for theme info + $defaults = array( + 'regions' => array( + 'left' => 'Left sidebar', + 'right' => 'Right sidebar', + 'content' => 'Content', + 'header' => 'Header', + 'footer' => 'Footer', + ), + 'description' => '', + 'features' => array( + 'comment_user_picture', + 'favicon', + 'mission', + 'logo', + 'name', + 'node_user_picture', + 'search', + 'slogan', + 'main_menu', + 'secondary_menu', + ), + 'stylesheets' => array( + 'all' => array('style.css') + ), + 'scripts' => array('script.js'), + 'screenshot' => 'screenshot.png', + 'php' => DRUPAL_MINIMUM_PHP, + ); $sub_themes = array(); // Read info files for each theme @@ -1079,6 +1156,18 @@ function _system_theme_data() { } /** + * Collect data about all currently available themes. + * + * @return + * Array of all available themes and their data. + */ +function system_get_theme_data() { + $themes = _system_get_theme_data(); + system_get_files_database($themes, 'theme', TRUE); + return $themes; +} + +/** * Recursive function to find the top level base theme. Themes can inherit * templates and function implementations from earlier themes. * Index: modules/update/update.compare.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.compare.inc,v retrieving revision 1.12 diff -u -p -r1.12 update.compare.inc --- modules/update/update.compare.inc 6 Sep 2008 08:36:22 -0000 1.12 +++ modules/update/update.compare.inc 7 Sep 2008 19:03:18 -0000 @@ -27,8 +27,8 @@ function update_get_projects() { $projects = update_project_cache('update_project_projects'); if (empty($projects)) { // Still empty, so we have to rebuild the cache. - _update_process_info_list($projects, module_rebuild_cache(), 'module'); - _update_process_info_list($projects, system_theme_data(), 'theme'); + _update_process_info_list($projects, system_get_module_data(), 'module'); + _update_process_info_list($projects, system_get_theme_data(), 'theme'); // Set the projects array into the cache table. cache_set('update_project_projects', $projects, 'cache_update', $_SERVER['REQUEST_TIME'] + 3600); }