Index: bp-core/bp-core-rewrite.php
===================================================================
--- bp-core/bp-core-rewrite.php
+++ bp-core/bp-core-rewrite.php
@@ -29,7 +29,7 @@ class BP_Rewrite {
 	 *
 	 * @var array
 	 */
-	public $registered_query_vars = array();
+	public $registered_query_vars = array( 'bp_component', 'bp_path' );
 
 	/**
 	 * Constructor.
@@ -38,7 +38,7 @@ class BP_Rewrite {
 		add_filter( 'query_vars',                array( $this, 'query_vars' ) );
 		add_action( 'bp_generate_rewrite_rules', array( $this, 'rewrite_rules' ),      999 );
 		add_action( 'bp_parse_query',            array( $this, 'parse_query' ),        2 );
-		add_action( 'bp_init',                   array( $this, 'setup_ajax_globals' ), 2  );
+		add_action( 'wp_loaded',                 array( $this, 'setup_ajax_globals' )  );
 		add_action( 'posts_request',             array( $this, 'posts_request' ),      10, 2 );
 	}
 
@@ -138,8 +138,7 @@ class BP_Rewrite {
 	 * function like bp_is_current_action() during AJAX, it will not work.  This
 	 * has the potential to break some plugins utilizing this behavior.
 	 *
-	 * Fortunately, our old URI globals function handles AJAX requests just fine,
-	 * so let's bring it off the bench durng AJAX.
+	 * To workaround this, we manually load up the WP query on AJAX here.
 	 */
 	public function setup_ajax_globals() {
 		// stop if we're not on an ajax request
@@ -147,17 +146,31 @@ class BP_Rewrite {
 			return;
 		}
 
-		// sigh... hello old friend, we're stuck with you at least for now.
-		bp_core_set_uri_globals();
+		// BP sends a 'cookie' parameter on AJAX requests
+		// If this AJAX request doesn't have this parameter, stop now!
+		if ( empty( $_POST['cookie'] ) ) {
+			return;
+		}
+
+		// Fool WP into using the referer for AJAX requests
+		// This is to pass WP::parse_request()'s stringent requirements
+		//
+		// @todo Needs further testing in different environments.
+		//       Especially PHP_SELF on IIS...
+		$_SERVER['PHP_SELF']    = 'index.php';
+		$_SERVER['REQUEST_URI'] = bp_core_referrer();
+
+		// manually load our custom 'bp_parse_query' hook
+		add_action( 'parse_query', array( $this, 'ajax_parse_query' ), 2 );
+
+		// load the WP query
+		wp();
 	}
 
 	/**
 	 * Add our query vars to WordPress.
 	 */
 	public function query_vars( $vars ) {
-		$this->registered_query_vars[] = 'bp_component';
-		$this->registered_query_vars[] = 'bp_path';
-
 		return array_merge( $this->registered_query_vars, $vars );
 	}
 
@@ -226,4 +239,19 @@ class BP_Rewrite {
 	public static function get_bp_frontpage_component() {
 		return self::get_bp_frontpage_component_from_page_id( get_option( 'page_on_front' ) );
 	}
+
+	/**
+	 * AJAX-capable version of {@link bp_parse_query()}.
+	 *
+	 * bp_parse_query() does not run in the admin area.  When AJAX is called, WP
+	 * assumes we are in the admin area.  As a consequence, our custom
+	 * 'parse_query' actions won't run.
+	 *
+	 * This is a stub method to allow the 'bp_parse_query' hook to run.
+	 *
+	 * @param object $query The current WP_Query instance.
+	 */
+	public function ajax_parse_query( $posts_query ) {
+		do_action_ref_array( 'bp_parse_query', array( &$posts_query ) );
+	}
 }
