diff --git a/includes/common.inc b/includes/common.inc index 8532e46c7097629ea9c6c8ae32be5b845e7c4195..aac56ef14b99df1a16f7201d4eaa09dc28245c2d 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5527,10 +5527,10 @@ function drupal_flush_all_caches() { // If invoked from update.php, we must not update the theme information in the // database, or this will result in all themes being disabled. if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') { - _system_get_theme_data(); + _system_rebuild_theme_data(); } else { - system_get_theme_data(); + system_rebuild_theme_data(); } drupal_theme_rebuild(); diff --git a/includes/install.inc b/includes/install.inc index 2e1f256d8130674e9286ad00c37981c0e4312da4..69e49c951a51ffd2f3b50a41cc5667befbf2cd1e 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -559,7 +559,7 @@ function drupal_verify_profile($install_state) { * Normally just testing wants to set this to TRUE. */ function drupal_install_modules($module_list = array(), $disable_modules_installed_hook = FALSE) { - $files = system_get_module_data(); + $files = system_rebuild_module_data(); $module_list = array_flip(array_values($module_list)); do { $moved = FALSE; @@ -654,7 +654,7 @@ function drupal_install_system() { ->execute(); // Now that we've installed things properly, bootstrap the full Drupal environment drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - system_get_module_data(); + system_rebuild_module_data(); } /** diff --git a/includes/registry.inc b/includes/registry.inc index cf2c09757206e91693cc38e2551db5354ea18d57..2bc98e0b16e9cf01fad52acfe7a4d5a42b2267ed 100644 --- a/includes/registry.inc +++ b/includes/registry.inc @@ -35,7 +35,7 @@ function _registry_rebuild() { require_once DRUPAL_ROOT . '/includes/database/' . $driver . '/query.inc'; // Get current list of modules and their files. - $modules = system_get_module_data(); + $modules = system_rebuild_module_data(); // Get the list of files we are going to parse. $files = array(); foreach ($modules as &$module) { diff --git a/includes/theme.inc b/includes/theme.inc index f17f10155bef58755099dc708fe01f6f7490be52..6edb3c73596d99b310b7719d9159e3c13769dcd4 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -569,7 +569,7 @@ function list_themes($refresh = FALSE) { } else { // Scan the installation when the database should not be read. - $themes = _system_get_theme_data(); + $themes = _system_rebuild_theme_data(); } foreach ($themes as $theme) { @@ -2342,7 +2342,7 @@ function template_preprocess_maintenance_page(&$variables) { global $theme; // Retrieve the theme data to list all available regions. - $theme_data = _system_get_theme_data(); + $theme_data = _system_rebuild_theme_data(); $regions = $theme_data[$theme]->info['regions']; // Get all region content set with drupal_add_region_content(). diff --git a/includes/update.inc b/includes/update.inc index a4005d3ef21393502e2c74f38ae1652088714281..f66e734c4a8c9c76973ac8635e5e6100b1f3accc 100644 --- a/includes/update.inc +++ b/includes/update.inc @@ -37,8 +37,8 @@ function update_check_incompatibility($name, $type = 'module') { // Store values of expensive functions for future use. if (empty($themes) || empty($modules)) { - $themes = _system_get_theme_data(); - $modules = system_get_module_data(); + $themes = _system_rebuild_theme_data(); + $modules = system_rebuild_module_data(); } if ($type == 'module' && isset($modules[$name])) { diff --git a/install.php b/install.php index 249d40729d594cc5e5301664aedf6b8c55f06684..d727e65fe96e4881751d97a7c97b20575a458024 100644 --- a/install.php +++ b/install.php @@ -1296,7 +1296,7 @@ function install_bootstrap_full(&$install_state) { */ function install_profile_modules(&$install_state) { $modules = variable_get('install_profile_modules', array()); - $files = system_get_module_data(); + $files = system_rebuild_module_data(); variable_del('install_profile_modules'); $operations = array(); foreach ($modules as $module) { diff --git a/modules/help/help.admin.inc b/modules/help/help.admin.inc index cb4411f1c9931f1430fa1630f926b99894fadd3f..c05d854f41272c27a9ae12ef74ddf7bbb6d7817c 100644 --- a/modules/help/help.admin.inc +++ b/modules/help/help.admin.inc @@ -47,7 +47,7 @@ function help_page($name) { function help_links_as_list() { $empty_arg = drupal_help_arg(); - $module_info = system_get_module_data(); + $module_info = system_rebuild_module_data(); $modules = array(); foreach (module_implements('help', TRUE) as $module) { diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index f2c278f77cc1ab07338a626a4d6e12a03a8b9e7a..e21c114ae403824fc00a6ec4d66c247a333df645 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -146,12 +146,11 @@ function system_admin_menu_block_page() { */ function system_admin_by_module() { - $modules = system_get_module_data(); + $module_info = system_get_info('module'); $menu_items = array(); $help_arg = module_exists('help') ? drupal_help_arg() : FALSE; - foreach ($modules as $file) { - $module = $file->name; + foreach ($module_info as $module => $info) { if ($module == 'help') { continue; } @@ -169,7 +168,7 @@ function system_admin_by_module() { // Sort. ksort($admin_tasks); - $menu_items[$file->info['name']] = array($file->info['description'], $admin_tasks); + $menu_items[$info['name']] = array($info['description'], $admin_tasks); } } return theme('system_admin_by_module', array('menu_items' => $menu_items)); @@ -200,7 +199,7 @@ function system_settings_overview() { */ function system_themes_form() { // Get current list of themes. - $themes = system_get_theme_data(); + $themes = system_rebuild_theme_data(); // Remove hidden themes from the display list. foreach ($themes as $theme_key => $theme) { @@ -396,7 +395,7 @@ function system_theme_settings($form, &$form_state, $key = '') { if ($key) { $settings = theme_get_settings($key); $var = str_replace('/', '_', 'theme_' . $key . '_settings'); - $themes = system_get_theme_data(); + $themes = system_rebuild_theme_data(); $features = $themes[$key]->info['features']; } else { @@ -643,7 +642,7 @@ function _system_is_incompatible(&$incompatible, $files, $file) { */ function system_modules($form, $form_state = array()) { // Get current list of modules. - $files = system_get_module_data(); + $files = system_rebuild_module_data(); // Remove hidden modules from display list. foreach ($files as $filename => $file) { @@ -834,7 +833,7 @@ function _system_modules_build_row($info, $extra) { * Display confirmation form for required modules. * * @param $modules - * Array of module file objects as returned from system_get_module_data(). + * Array of module file objects as returned from system_rebuild_module_data(). * @param $storage * The contents of $form_state['storage']; an array with two * elements: the list of required modules and the list of status @@ -891,7 +890,7 @@ function system_modules_submit($form, &$form_state) { // Get a list of all modules, it will be used to find which module requires // which. - $files = system_get_module_data(); + $files = system_rebuild_module_data(); // The modules to be enabled. $modules_to_be_enabled = array(); diff --git a/modules/system/system.api.php b/modules/system/system.api.php index e8e4f5935706f0956e0e154f0e5a80c438850a08..186899273c45d2f5a2e83d40209198ebd723fb2d 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -720,9 +720,10 @@ function hook_mail_alter(&$message) { /** * Alter the information parsed from module and theme .info files * - * This hook is invoked in _system_get_module_data() and in _system_get_theme_data(). - * A module may implement this hook in order to add to or alter the data - * generated by reading the .info file with drupal_parse_info_file(). + * This hook is invoked in _system_rebuild_module_data() and in + * _system_rebuild_theme_data(). A module may implement this hook in order to + * add to or alter the data generated by reading the .info file with + * drupal_parse_info_file(). * * @param &$info * The .info file contents, passed by reference so that it can be altered. diff --git a/modules/system/system.install b/modules/system/system.install index 4febc30e8d90e233a52eb7756a826206174c06cb..08ecacd5e647e449acb1eef3d0c9a609cd0b9945 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -345,12 +345,12 @@ function system_install() { } // Clear out module list and hook implementation statics before calling - // system_get_theme_data(). + // system_rebuild_theme_data(). module_list(TRUE); module_implements('', FALSE, TRUE); // Load system theme data appropriately. - system_get_theme_data(); + system_rebuild_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 @@ -2212,7 +2212,7 @@ function system_update_7021() { variable_del('site_footer'); // Rebuild theme data, so the new 'help' region is identified. - system_get_theme_data(); + system_rebuild_theme_data(); } /** diff --git a/modules/system/system.module b/modules/system/system.module index 8ddfea03f71cd1d1f699d7765ee693ca080c9a80..483ea86437d6a8f3bbf98620c0262cf7e676cead 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1846,13 +1846,36 @@ function system_update_files_database(&$files, $type) { $query->execute(); } +/** + * Returns an array of information about active modules or themes. + * + * This function returns the information from the {system} table corresponding + * to the cached contents of the .info file for each active module or theme. + * + * @param $type + * Either 'module' or 'theme'. + * @return + * An associative array of module or theme information keyed by name. + * + * @see system_rebuild_module_data() + * @see system_rebuild_theme_data() + */ +function system_get_info($type) { + $info = array(); + $result = db_query('SELECT name, info FROM {system} WHERE type = :type AND status = 1', array(':type' => $type)); + foreach ($result as $item) { + $info[$item->name] = unserialize($item->info); + } + return $info; +} + /** * Helper function to scan and collect module .info data. * * @return * An associative array of module information. */ -function _system_get_module_data() { +function _system_rebuild_module_data() { // Find modules $modules = drupal_system_listing('/\.module$/', 'modules', 'name', 0); @@ -1903,13 +1926,13 @@ function _system_get_module_data() { } /** - * Collect data about all currently available modules. + * Rebuild, save, and return 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(); +function system_rebuild_module_data() { + $modules = _system_rebuild_module_data(); ksort($modules); system_get_files_database($modules, 'module'); system_update_files_database($modules, 'module'); @@ -1939,7 +1962,7 @@ function system_get_module_data() { * @return * An associative array of themes information. */ -function _system_get_theme_data() { +function _system_rebuild_theme_data() { $themes_info = &drupal_static(__FUNCTION__, array()); if (empty($themes_info)) { @@ -2065,13 +2088,13 @@ function _system_get_theme_data() { } /** - * Collect data about all currently available themes. + * Rebuild, save, and return 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(); +function system_rebuild_theme_data() { + $themes = _system_rebuild_theme_data(); ksort($themes); system_get_files_database($themes, 'theme'); system_update_files_database($themes, 'theme'); diff --git a/modules/update/update.compare.inc b/modules/update/update.compare.inc index 389c30d7625e40bc67516b8898eb59d9d4f55260..337d5eb6e7fc68b8c004cc6f6f700984d495ae51 100644 --- a/modules/update/update.compare.inc +++ b/modules/update/update.compare.inc @@ -36,8 +36,8 @@ function update_get_projects() { $projects = update_project_cache('update_project_projects'); if (empty($projects)) { // Still empty, so we have to rebuild the cache. - $module_data = system_get_module_data(); - $theme_data = system_get_theme_data(); + $module_data = system_rebuild_module_data(); + $theme_data = system_rebuild_theme_data(); _update_process_info_list($projects, $module_data, 'module', TRUE); _update_process_info_list($projects, $theme_data, 'theme', TRUE); if (variable_get('update_check_disabled', FALSE)) { diff --git a/modules/update/update.test b/modules/update/update.test index 7c5a2f0f871884c12bcfb20857ae6f923cb1dfc9..220c814945967ae9c9c2f6a3d35299e47e00460f 100644 --- a/modules/update/update.test +++ b/modules/update/update.test @@ -250,7 +250,7 @@ class UpdateTestContribCase extends UpdateTestHelper { * "CCC Update test" project. We need to make sure that we see the "BBB" * project before the "CCC" project, even though "CCC" includes a module * that's processed first if you sort alphabetically by module name (which - * is the order we see things inside system_get_module_data() for example). + * is the order we see things inside system_rebuild_module_data() for example). */ function testUpdateContribOrder() { // We want core to be version 7.0.