Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 6166)
+++ wp-includes/functions.php	(working copy)
@@ -726,9 +726,12 @@
 }
 
 function wp($query_vars = '') {
-	global $wp;
+	global $wp, $wp_query, $wp_the_query;
 
 	$wp->main($query_vars);
+
+	if( !isset($wp_the_query) )
+		$wp_the_query = $wp_query;
 }
 
 function get_status_header_desc( $code ) {

