Index: query.php
===================================================================
--- query.php	(revision 40809)
+++ query.php	(working copy)
@@ -25,6 +25,10 @@
  */
 function get_query_var( $var, $default = '' ) {
 	global $wp_query;
+	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;
+	}
 	return $wp_query->get( $var, $default );
 }
 
