Index: src/wp-includes/query.php
===================================================================
--- src/wp-includes/query.php	(revision 40960)
+++ src/wp-includes/query.php	(working copy)
@@ -25,7 +25,12 @@
  */
 function get_query_var( $var, $default = '' ) {
 	global $wp_query;
-	return $wp_query->get( $var, $default );
+        if ( ! isset( $wp_query ) ) { 
+ 		                _doing_it_wrong( __FUNCTION__, __( 'Retrieving query variables will not work before the query is run. Before then, they always return false.' ), '3.1.0' ); 
+ 		                return false; 
+        } else {
+		 return $wp_query->get( $var, $default ); 
+	}	
 }
 
 /**
