Index: includes/module.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/module.inc,v retrieving revision 1.197 diff -u -p -r1.197 module.inc --- includes/module.inc 28 Jul 2010 01:46:59 -0000 1.197 +++ includes/module.inc 23 Aug 2010 06:16:51 -0000 @@ -72,7 +72,8 @@ function module_list($refresh = FALSE, $ $list = system_list('bootstrap'); } else { - $list = system_list('module_enabled'); + $list = array_keys(system_list('module_enabled')); + $list = (!empty($list) ? array_combine($list, $list) : array()); } } } @@ -96,9 +97,10 @@ function module_list($refresh = FALSE, $ * - theme: All themes. * * @return - * An associative array of modules or themes, keyed by name, and having the - * respective database row as value. For $type 'module_enabled' and - * 'bootstrap', the array values equal the keys. + * An associative array of modules or themes, keyed by name. For $type + * 'bootstrap', the array values equal the keys. For $type 'module_enabled' + * or 'theme', the array values are objects representing the respective + * database row, with the 'info' property already unserialized. * * @see module_list() * @see list_themes() @@ -143,11 +145,12 @@ function system_list($type) { // Drupal installations, which might have modules installed in different // locations in the file system. The ordering here must also be // consistent with the one used in module_implements(). - $result = db_query("SELECT * FROM {system} ORDER BY weight ASC, name ASC"); + $result = db_query("SELECT * FROM {system} WHERE type = 'theme' OR (type = 'module' AND status = 1) ORDER BY weight ASC, name ASC"); foreach ($result as $record) { - if ($record->type == 'module' && $record->status) { - // Build a list of all enabled modules. - $lists['module_enabled'][$record->name] = $record->name; + $record->info = unserialize($record->info); + // Build a list of all enabled modules. + if ($record->type == 'module') { + $lists['module_enabled'][$record->name] = $record; } // Build a list of themes. if ($record->type == 'theme') { Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.606 diff -u -p -r1.606 theme.inc --- includes/theme.inc 22 Aug 2010 12:46:21 -0000 1.606 +++ includes/theme.inc 23 Aug 2010 06:16:51 -0000 @@ -583,7 +583,6 @@ function list_themes($refresh = FALSE) { try { foreach (system_list('theme') as $theme) { if (file_exists($theme->filename)) { - $theme->info = unserialize($theme->info); $themes[] = $theme; } } Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.957 diff -u -p -r1.957 system.module --- modules/system/system.module 22 Aug 2010 13:52:58 -0000 1.957 +++ modules/system/system.module 23 Aug 2010 06:16:52 -0000 @@ -2217,25 +2217,40 @@ function system_update_files_database(&$ } /** - * Returns an array of information about active modules or themes. + * Returns an array of information about enabled 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'. + * @param $name + * (optional) The name of a module or theme whose information shall be + * returned. If omitted, all records for the provided $type will be returned. + * If $name does not exist in the provided $type or is not enabled, an empty + * array will be returned. * * @return - * An associative array of module or theme information keyed by name. + * An associative array of module or theme information keyed by name, or only + * information for $name, if given. If no records are available, an empty + * array is returned. * * @see system_rebuild_module_data() * @see system_rebuild_theme_data() */ -function system_get_info($type) { +function system_get_info($type, $name = NULL) { $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); + if ($type == 'module') { + $type = 'module_enabled'; + } + $list = system_list($type); + foreach ($list as $shortname => $item) { + if (!empty($item->status)) { + $info[$shortname] = $item->info; + } + } + if (isset($name)) { + return isset($info[$name]) ? $info[$name] : array(); } return $info; }