title: Using tax_query creates a 0 = 1 in $wp_query->request
body: <p>This is my first attempt at modifying the main query using the <code>pre_get_posts</code> action/filter</p>
  
  <p>This is the function currently hooked to it:</p>
  
  <pre><code>function advanced_product_search_filter($query)
  {
    if(!is_admin() &amp;&amp;
       is_main_query() &amp;&amp; 
       is_search() &amp;&amp; $query-&gt;query_vars['post_type'] == 'product')
    {
      $keyword = $_GET['s'];
  
      if($_GET['exactly'])
        $keyword = $_GET['s'] . ' "'. $_GET['exactly'] . '"';
  
      if($_GET['without'])
      {
        $excluded = exclude_product_keyword_search($_GET['without'], 
                      $_GET['pname'],
                      $_GET['pcode']
                    );
        $query-&gt;set('post__not_in', $excluded);
      }
  
      if($_GET['pname'])
        $query-&gt;set('s', $keyword);
      else
        $query-&gt;set('s', '');
  
      if($_GET['pcode'])
      {
        $tax_queries = $query-&gt;get('tax_query');
        $tax_queries[] = array(
          array(
            'taxonomy' =&gt; 'pa_ordering-code',
            'field' =&gt; 'name',
            'terms' =&gt; array($keyword),
            'operator' =&gt; 'LIKE'
          )
        );
        $query-&gt;set('tax_query', $tax_queries);
      }
    }
  }
  </code></pre>
  
  <p>This is a plugin built on top of a <code>WooCommerce</code> installation. So basically this function <em>tries</em> to support searching a <code>WooCommerce</code> product either through the standard search (title and content) or an attribute search on a custom attribute called <code>Ordering Code</code> which is <code>pa_ordering-code</code> in the <code>term_taxonomy</code> table</p>
  
  <p>Other parts of the code works fine, I can modify the <code>s</code> and <code>post__not_in</code> vars without any problems, but if I try to use the <code>tax_query</code> it, the query seems to break down.</p>
  
  <p>To give you an idea, when I try this:</p>
  
  <pre><code>?s=foo&amp;post_type=product&amp;pname=1&amp;pcode=1&amp;without=non&amp;exactly=foo+bar
  </code></pre>
  
  <p>dumping the <code>WHERE</code> clause, I see this:</p>
  
  <pre><code>AND wp_posts.ID NOT IN (219) 
  AND 0 = 1 
  AND 
  (
    (
      (wp_posts.post_title LIKE '%foo%') OR 
      (wp_posts.post_content LIKE '%foo%')
    ) AND (
      (wp_posts.post_title LIKE '%foo bar%') OR 
      (wp_posts.post_content LIKE '%foo bar%')
    )
  ) 
  AND wp_posts.post_type = 'product' 
  AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') 
  AND
  ( 
    (
      wp_postmeta.meta_key = '_visibility' AND
      CAST(wp_postmeta.meta_value AS CHAR) IN ('visible','search')
    ) 
  )
  </code></pre>
  
  <p>Notice the <code>AND 0 = 1</code>? When I dump the <code>JOIN</code> clause, I become sure that the <code>tax_query</code> parameter isn't being interpreted properly since I only see the <code>postmeta</code> table in there. No <code>terms</code>, <code>term_relationships</code>, or <code>term_taxonomy</code> table.</p>
  
  <p>And I also tried simply overwriting the existing <code>tax_query</code> (if there is one) by doing this:</p>
  
  <pre><code>$args = array(
    array(
      'taxonomy' =&gt; 'pa_ordering-code',
      'field' =&gt; 'name',
      'terms' =&gt; array($keyword),
      'operator' =&gt; 'LIKE'
    )
  );
  $query-&gt;set('tax_query', $args);
  </code></pre>
  
  <p>But I still could not get it to work. Any ideas as to what I may be doing wrong?</p>