[wp-trac] [WordPress Trac] #22112: get_adjacent_post excluded_categories isn't excluded
WordPress Trac
noreply at wordpress.org
Fri Aug 29 00:53:09 UTC 2014
#22112: get_adjacent_post excluded_categories isn't excluded
-------------------------------------------------+-------------------------
Reporter: PatNarciso | Owner:
Type: defect (bug) | wonderboymusic
Priority: normal | Status: reopened
Component: Posts, Post Types | Milestone: 4.0
Severity: normal | Version: 3.8.1
Keywords: 2nd-opinion has-patch dev-feedback | Resolution:
commit | Focuses: template
-------------------------------------------------+-------------------------
Changes (by betzster):
* status: closed => reopened
* resolution: fixed =>
Comment:
I don't think we need a subquery here. Excluding the `$excluded_terms`
from `$term_array` should be enough to solve the original issue. We do
need to check that `$term_array` is valid (it exists and is not an error)
before manipulating it though.
22112.3.patch fixes this.
Currently in trunk:
{{{
mysql> EXPLAIN SELECT p.ID FROM wp_posts AS p INNER JOIN
wp_term_relationships AS tr ON p.ID = tr.object_id INNER JOIN
wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE
p.post_date < '2014-08-26 14:01:03' AND p.post_type = 'post' AND
p.post_status = 'publish' AND tt.taxonomy = 'category' AND tt.term_id IN
(7386,193894091,828) AND p.ID NOT IN ( SELECT object_id FROM
wp_term_relationships WHERE term_taxonomy_id IN (22006310) ) ORDER BY
p.post_date DESC LIMIT 1;
+----+--------------------+-----------------------+-----------------+-----------------------------------+------------------+---------+-------------------------------+------+----------------------------------------------+
| id | select_type | table | type |
possible_keys | key | key_len | ref
| rows | Extra |
+----+--------------------+-----------------------+-----------------+-----------------------------------+------------------+---------+-------------------------------+------+----------------------------------------------+
| 1 | PRIMARY | tt | range |
PRIMARY,term_id_taxonomy,taxonomy | term_id_taxonomy | 106 | NULL
| 3 | Using where; Using temporary; Using filesort |
| 1 | PRIMARY | tr | ref |
PRIMARY,term_taxonomy_id | term_taxonomy_id | 8 |
wordpress.tt.term_taxonomy_id | 11 | Using where
|
| 1 | PRIMARY | p | eq_ref |
PRIMARY,type_status_date | PRIMARY | 8 |
wordpress.tr.object_id | 1 | Using where
|
| 2 | DEPENDENT SUBQUERY | wp_term_relationships | unique_subquery |
PRIMARY,term_taxonomy_id | PRIMARY | 16 |
func,const | 1 | Using index; Using where
|
+----+--------------------+-----------------------+-----------------+-----------------------------------+------------------+---------+-------------------------------+------+----------------------------------------------+
}}}
With 22112.3.patch:
{{{
mysql> EXPLAIN SELECT p.ID FROM wp_posts AS p INNER JOIN
wp_term_relationships AS tr ON p.ID = tr.object_id INNER JOIN
wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE
p.post_date < '2014-08-26 14:01:03' AND p.post_type = 'post' AND
p.post_status = 'publish' AND tt.taxonomy = 'category' AND tt.term_id IN
(7386,193894091,828) AND tt.taxonomy = 'category' AND tt.term_id NOT IN
(22006310) ORDER BY p.post_date DESC LIMIT 1;
+----+-------------+-------+--------+-----------------------------------+------------------+---------+-------------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys |
key | key_len | ref | rows | Extra
|
+----+-------------+-------+--------+-----------------------------------+------------------+---------+-------------------------------+------+----------------------------------------------+
| 1 | SIMPLE | tt | range | PRIMARY,term_id_taxonomy,taxonomy |
term_id_taxonomy | 106 | NULL | 3 | Using
where; Using temporary; Using filesort |
| 1 | SIMPLE | tr | ref | PRIMARY,term_taxonomy_id |
term_taxonomy_id | 8 | wordpress.tt.term_taxonomy_id | 11 |
|
| 1 | SIMPLE | p | eq_ref | PRIMARY,type_status_date |
PRIMARY | 8 | wordpress.tr.object_id | 1 | Using
where |
+----+-------------+-------+--------+-----------------------------------+------------------+---------+-------------------------------+------+----------------------------------------------+
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/22112#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list