WordPress.org

Make WordPress Core

Changeset 30405


Ignore:
Timestamp:
11/20/2014 10:58:42 AM (5 years ago)
Author:
nacin
Message:

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

Merges [30263] (and [30264] [30401]) to the 4.0 branch.

props boonebgorges.
fixes #29663, see #22112.

Location:
branches/4.0
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/4.0

  • branches/4.0/src/wp-includes/link-template.php

    r30260 r30405  
    15141514
    15151515        if ( ! empty( $excluded_terms ) ) {
    1516             $where .= " AND p.ID NOT IN ( SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (" . implode( $excluded_terms, ',' ) . ') )';
     1516            $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, ',' ) . ') )';
    15171517        }
    15181518    }
  • branches/4.0/tests/phpunit/tests/link.php

    r29248 r30405  
    191191
    192192    /**
    193     * @ticket 22112
    194     */
     193     * @ticket 22112
     194     */
    195195    function test_get_adjacent_post_exclude_self_term() {
    196         $include = $this->factory->category->create();
     196        // Bump term_taxonomy to mimic shared term offsets.
     197        global $wpdb;
     198        $wpdb->insert( $wpdb->term_taxonomy, array( 'taxonomy' => 'foo', 'term_id' => 12345, 'description' => '' ) );
     199
     200        $include = $this->factory->term->create( array(
     201            'taxonomy' => 'category',
     202            'name' => 'Include',
     203        ) );
    197204        $exclude = $this->factory->category->create();
    198205
Note: See TracChangeset for help on using the changeset viewer.