WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/12/2015 08:33:07 PM (6 years ago)
Author:
boonebgorges
Message:

Remove extraneous table join in get_adjacent_post().

Since [29248], a table join has not been necessary to process the
$excluded_terms parameter of get_adjacent_post(). Aside from adding extra
overhead, this join meant that post records that don't have any corresponding
rows in wp_term_relationships were erroneously excluded from results.

Fixes #32833.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r34042 r34088  
    14931493
    14941494    if ( $in_same_term || ! empty( $excluded_terms ) ) {
    1495         $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
    1496         $where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
    1497 
    14981495        if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
    14991496            // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
     
    15091506
    15101507        if ( $in_same_term ) {
     1508            $join .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
     1509            $where .= $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
     1510
    15111511            if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) )
    15121512                return '';
Note: See TracChangeset for help on using the changeset viewer.