[wp-trac] [WordPress Trac] #27043: tax_query limited from 3.6 to 3.7
WordPress Trac
noreply at wordpress.org
Sat Feb 8 03:09:14 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 | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Comment (by AdamCapriola):
I'm not sure the best way to post this, but I set up clean development
sites with 3.6.1 and 3.8.1, added my custom taxonomies, post types, and
custom theme, created a few posts, and then ran the same queries on both
installations with the SQL Monitor plugin active. (If there is a better
way to monitor the SQL, please let me know.)
Here is where I found the biggest difference in the SQL...
----
'''WordPress 3.6.1 (3 Tax Query Arguments)'''
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN
wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id)
INNER JOIN wp_term_relationships AS tt2 ON (wp_posts.ID = tt2.object_id)
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1
AND ( wp_term_relationships.term_taxonomy_id IN (13) AND
tt1.term_taxonomy_id IN (4) AND tt2.term_taxonomy_id IN (5) ) AND
wp_posts.post_type = 'pkmn_card' AND (wp_posts.post_status = 'publish' OR
wp_posts.post_status = 'private') AND (wp_postmeta.meta_key =
'release_date_unix' ) GROUP BY wp_posts.ID ORDER BY
wp_postmeta.meta_value+0 DESC LIMIT 0, 20
SELECT FOUND_ROWS()
etc...
'''WordPress 3.8.1 (3 Tax Query Arguments)'''
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN
wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id)
INNER JOIN wp_term_relationships AS tt2 ON (wp_posts.ID = tt2.object_id)
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1
AND ( wp_term_relationships.term_taxonomy_id IN (13) AND
tt1.term_taxonomy_id IN (4) AND tt2.term_taxonomy_id IN (5) ) '''AND
(((wp_posts.post_title LIKE '% %') OR (wp_posts.post_content LIKE '%
%')))''' AND wp_posts.post_type = 'pkmn_card' AND (wp_posts.post_status =
'publish' OR wp_posts.post_status = 'private') AND (wp_postmeta.meta_key =
'release_date_unix' ) GROUP BY wp_posts.ID ORDER BY
wp_postmeta.meta_value+0 DESC LIMIT 0, 20
No other SQL runs after that.
----
'''WordPress 3.6.1 (2 Tax Query Arguments)'''
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN
wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id)
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1
AND ( wp_term_relationships.term_taxonomy_id IN (4) AND
tt1.term_taxonomy_id IN (5) ) AND wp_posts.post_type = 'pkmn_card' AND
(wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND
(wp_postmeta.meta_key = 'release_date_unix' ) GROUP BY wp_posts.ID ORDER
BY wp_postmeta.meta_value+0 DESC LIMIT 0, 20
SELECT FOUND_ROWS()
etc...
'''WordPress 3.8.1 (2 Tax Query Arguments)'''
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN
wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id)
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1
AND ( wp_term_relationships.term_taxonomy_id IN (4) AND
tt1.term_taxonomy_id IN (5) ) '''AND (((wp_posts.post_title LIKE '% %') OR
(wp_posts.post_content LIKE '% %')))''' AND wp_posts.post_type =
'pkmn_card' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status
= 'private') AND (wp_postmeta.meta_key = 'release_date_unix' ) GROUP BY
wp_posts.ID ORDER BY wp_postmeta.meta_value+0 DESC LIMIT 0, 20
SELECT FOUND_ROWS()
etc...
----
`AND (((wp_posts.post_title LIKE '% %') OR (wp_posts.post_content LIKE '%
%')))` is the only difference between both, but for whatever reason kills
the query when there are three or more tax_query arguments; two or less
and it has no effect.
So, now knowing that's what changed after WordPress 3.6.1, I tried adding
a string to the `s` argument of the query to match part of a post title,
and I was able to get results to return in WordPress 3.8.1 with three or
more tax_query arguments.
Perhaps there can be some kind of a check, so that if `s` is empty then
that part doesn't get added to the query? I think that's what throwing it
off.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27043#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list