[wp-trac] [WordPress Trac] #27043: tax_query limited from 3.6 to 3.7

WordPress Trac noreply at wordpress.org
Thu Feb 6 21:27:06 UTC 2014


#27043: tax_query limited from 3.6 to 3.7
--------------------------+-----------------------------
 Reporter:  AdamCapriola  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  3.8.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 A few months ago I upgraded from 3.6 to 3.7 (and now subsequently 3.8.1)
 and noticed on a database focused WordPress site I run that whenever I do
 an advanced search (via a customized form on the frontend) where I set a
 tax_query with more than two arguments, the search returns no results. Two
 or less arguments and results are returned as expected.

 I've ruled out any plugins effecting this (I disabled all of them) and I
 can't really test on a default theme since I've done heavy customization
 on my site with custom taxonomies and whatnot to allow the advanced
 searches on the frontend, but I also tested locally on my computer, and as
 soon as I upgraded to 3.7 the searches with more than two tax_query
 arguments stopped working. The functionality worked fine through 3.6.

 And to clarify, by more than two tax_query arguments I mean something like
 this:

 {{{
 add_filter( 'pre_get_posts', 'ac_filter_search' );

 function ac_filter_search( $query ) {

         // Argument 1
         $tax_query[] = array(
                 'taxonomy' => 'tax1',
                 'field' => 'slug',
                 'terms' => 'term1',
                 'operator' => 'IN'
         );

         // Argument 2
         $tax_query[] = array(
                 'taxonomy' => 'tax2',
                 'field' => 'slug',
                 'terms' => 'term2',
                 'operator' => 'IN'
         );

         // Argument 3
         $tax_query[] = array(
                 'taxonomy' => 'tax3',
                 'field' => 'slug',
                 'terms' => 'term3',
                 'operator' => 'IN'
         );

         $query->set( 'tax_query', $tax_query );

         return $query;

 }
 }}}

 I know the way search results are returned was altered in 3.7 to show more
 relevant results, but why would something fairly simple like this be
 affected?

 Here are the actual var_exported $query variables for a working search and
 a broken one (the only differences are in tax_query).

 Working: https://gist.github.com/adamcapriola/b7ae3b22e7f99e8bb3ee
 Broken: https://gist.github.com/adamcapriola/cc549fc2d77a4d21b8cb

 And interestly enough this following three argument tax_query does returns
 its expected results for some reason (I am thinking because it only has
 two 'IN' operators and one 'NOT IN' – the non-working example has three
 'IN'):

 https://gist.github.com/adamcapriola/86e0d53fe60ae1bc25e5

 Any idea what's going on or what changed between 3.6 and 3.7?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27043>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list