[wp-trac] [WordPress Trac] #43324: query_vars is not necessarely representative of the final query_vars used to build the SQL query

WordPress Trac noreply at wordpress.org
Wed Feb 14 23:53:59 UTC 2018


#43324: query_vars is not necessarely representative of the final query_vars used
to build the SQL query
--------------------------+-----------------------------
 Reporter:  msaggiorato   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I've recently stumbled upon a case here where the post_type query_var
 changes over the process of the query building process, and the change is
 not reflected in the query_vars variable of the query.

 On the section highlighted
 [https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-
 query.php#L2067-L2088 here] (sorry for pasting a GitHub link, i just
 wanted to use the section highlighting feature), you can see that if
 there's no post_type set in the query, but you're querying taxonomies (eg
 a tax archive query), the post_type is set (using a separate variable),
 and then used on the [https://github.com/WordPress/WordPress/blob/master
 /wp-includes/class-wp-query.php#L2345-L2366 following section] to build up
 the where statement.

 In my opinion all of the query_vars modified during the process should be
 reflected in the query_vars variable, so you can after see the actual
 value being used for querying (on the {{{posts_request}}} filter for
 example).

 You can see [https://github.com/WordPress/WordPress/blob/master/wp-
 includes/class-wp-query.php#L2152-L2160 here] a section where the
 {{{$q['author']}}, {{{$q['author__in']}}} and {{{$q['author__not_in']}}}.
 These is an example of changes that are not reflected in the query_vars
 (since there's no call to fill_query_vars after all this extra parsing,
 sanitizing, and defaulting process is made).

 Let me know your thoughts.

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


More information about the wp-trac mailing list