In `get_adjacent_post()`, `$excluded_terms` should check term_id rather than term_taxonom_id.

See #29663, #22112.

git-svn-id: https://develop.svn.wordpress.org/trunk@30263 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2014-11-06 20:11:34 +00:00
parent 49d5227e76
commit 6f7880bcf4
2 changed files with 11 additions and 4 deletions

View File

@ -1513,7 +1513,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
}
if ( ! empty( $excluded_terms ) ) {
$where .= " AND p.ID NOT IN ( SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (" . implode( $excluded_terms, ',' ) . ') )';
$where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( $excluded_terms, ',' ) . ') )';
}
}

View File

@ -193,7 +193,14 @@ class Tests_Link extends WP_UnitTestCase {
* @ticket 22112
*/
function test_get_adjacent_post_exclude_self_term() {
$include = $this->factory->category->create();
// Bump term_taxonomy to mimic shared term offsets.
global $wpdb;
$wpdb->insert( $wpdb->term_taxonomy, array( 'taxonomy' => 'foo', 'term_id' => 12345 ) );
$include = $this->factory->term->create( array(
'taxonomy' => 'category',
'name' => 'Include',
) );
$exclude = $this->factory->category->create();
$one = $this->factory->post->create_and_get( array(