Index: wp-includes/class-wp-theme.php
===================================================================
--- wp-includes/class-wp-theme.php	(revision 22717)
+++ wp-includes/class-wp-theme.php	(working copy)
@@ -238,6 +238,25 @@
 				return;
 			}
 		}
+		
+		// Set the parent, if we're a child theme.
+		if ( $this->template != $this->stylesheet ) {
+			// If we are a parent, then there is a problem. Only two generations allowed! Cancel things out.
+			if ( is_a( $_child, 'WP_Theme' ) && $_child->template == $this->stylesheet ) {
+				$_child->parent = null;
+				$_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $_child->template ) );
+				$_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) );
+				// The two themes actually reference each other with the Template header.
+				if ( $_child->stylesheet == $this->template ) {
+					$this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $this->template ) );
+					$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
+				}
+				
+				return;
+			}
+			// Set the parent. Pass the current instance so we can do the crazy checks above and assess errors.
+			$this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this );
+		}		
 
 		// If we got our data from cache, we can assume that 'template' is pointing to the right place.
 		if ( ! is_array( $cache ) && $this->template != $this->stylesheet && ! file_exists( $this->theme_root . '/' . $this->template . '/index.php' ) ) {
@@ -258,24 +277,6 @@
 			}
 		}
 
-		// Set the parent, if we're a child theme.
-		if ( $this->template != $this->stylesheet ) {
-			// If we are a parent, then there is a problem. Only two generations allowed! Cancel things out.
-			if ( is_a( $_child, 'WP_Theme' ) && $_child->template == $this->stylesheet ) {
-				$_child->parent = null;
-				$_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $_child->template ) );
-				$_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) );
-				// The two themes actually reference each other with the Template header.
-				if ( $_child->stylesheet == $this->template ) {
-					$this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $this->template ) );
-					$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
-				}
-				return;
-			}
-			// Set the parent. Pass the current instance so we can do the crazy checks above and assess errors.
-			$this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this );
-		}
-
 		// We're good. If we didn't retrieve from cache, set it.
 		if ( ! is_array( $cache ) ) {
 			$cache = array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template );
