parisholley/wordpress-fantastic-elasticsearch — pull request #101 by barryhughes (2014-11-19 19:05:30+00:00)
Title: Do not overwrite $wp_query with global symbol of the same name

`AbstractArchive::do_search()` accepts a `$wp_query` parameter but was immediately overwriting it by importing the global of the same name.

The problem we found this to cause was that if other plugins create WP_Query object *before* the main query runs, `$wp_query->is_main_query()` would naturally evaluate as true (because the test is against the _global_ `$wp_query`, not the query that's actually running).

The `attempted` flag is then set to true and, when the main query finally comes in, `do_search()` bails prematurely:

``` php
// pre_get_posts fires and the $wp_query object comes in:
function do_search($wp_query){
// It is immediately overwritten by a global import
global $wp_query

// Now we're testing to see if the global $wp_query is the main query ... it will be
if(!$wp_query->is_main_query() || is_admin() || $this->attempted){
return;
}

// This flag is set prematurely ... when the main query actually runs this method
// will have bailed already
$this->attempted = true;
```

This pull request simply removes the `global $wp_query` import, avoiding this issue when and if other plugins generate their own queries early in the request.