### Eclipse Workspace Patch 1.0
#P wordpress-trunk
Index: wp-includes/theme.php
===================================================================
--- wp-includes/theme.php	(revision 12546)
+++ wp-includes/theme.php	(working copy)
@@ -263,7 +263,8 @@
 
 	asort( $theme_files );
 
-	$wp_themes = array();
+	$theme_roots = array();
+	$wp_themes   = array();
 
 	foreach ( (array) $theme_files as $theme_file ) {
 		$theme_root = $theme_file['theme_root'];
@@ -427,18 +428,20 @@
 
 /**
  * Retrieve theme roots.
+ * 
+ * Theme roots are pathes to theme directories.
  *
  * @since 2.9.0
  *
- * @return array Theme roots
+ * @return array directories of all theme-roots keyed with their stylesheet value
  */
 function get_theme_roots() {
 	$theme_roots = get_site_transient( 'theme_roots' );
 	if ( false === $theme_roots ) {
 		get_themes();
-		$theme_roots = get_site_transient( 'theme_roots' ); // this is set in get_theme()
+		$theme_roots = get_site_transient( 'theme_roots' ); // set in get_themes()
 	}
-	return $theme_roots;
+	return (array) $theme_roots;
 }
 
 /**
@@ -470,28 +473,30 @@
  * @return string
  */
 function get_current_theme() {
+	// magic number
+	$default_theme      = 'WordPress Default';
+
 	if ( $theme = get_option('current_theme') )
 		return $theme;
 
 	$themes = get_themes();
-	$theme_names = array_keys($themes);
-	$current_template = get_option('template');
-	$current_stylesheet = get_option('stylesheet');
-	$current_theme = 'WordPress Default';
+	if ( ! is_array($themes) )
+		return $default_theme;
 
-	if ( $themes ) {
-		foreach ( (array) $theme_names as $theme_name ) {
-			if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
-					$themes[$theme_name]['Template'] == $current_template ) {
-				$current_theme = $themes[$theme_name]['Name'];
-				break;
-			}
+	$theme      = $default_theme;
+	$template   = get_option('template');
+	$stylesheet = get_option('stylesheet');
+
+	foreach ( $themes as $value ) {
+		if ( $value['Stylesheet']  == $stylesheet
+		     && $value['Template'] == $template ) {
+			$theme = $value['Name'];
+			break;
 		}
 	}
 
-	update_option('current_theme', $current_theme);
-
-	return $current_theme;
+	update_option('current_theme', $theme);
+	return $theme;
 }
 
 /**
