From e0b1340461e13e2e349297cc0ba710f38605498d Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 12 Sep 2015 20:34:24 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@34088 git-svn-id: http://core.svn.wordpress.org/trunk@34056 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 6 +++--- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index ae01e6fe0c..dd04b24731 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1492,9 +1492,6 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo $where = ''; if ( $in_same_term || ! empty( $excluded_terms ) ) { - $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"; - $where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); - if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and " if ( false !== strpos( $excluded_terms, ' and ' ) ) { @@ -1508,6 +1505,9 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo } if ( $in_same_term ) { + $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"; + $where .= $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); + if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) return ''; $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index d82ef819a9..0019ac6a5b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34087'; +$wp_version = '4.4-alpha-34088'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.