diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 6ff622f257..d4cf7b55cd 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1976,9 +1976,15 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo */ $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post, $order ); - $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; - $query_key = 'adjacent_post_' . md5( $query ); - $result = wp_cache_get( $query_key, 'counts' ); + $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; + $key = md5( $query ); + $last_changed = wp_cache_get_last_changed( 'posts' ); + if ( $in_same_term || ! empty( $excluded_terms ) ) { + $last_changed .= wp_cache_get_last_changed( 'terms' ); + } + $cache_key = "adjacent_post:$key:$last_changed"; + + $result = wp_cache_get( $cache_key, 'posts' ); if ( false !== $result ) { if ( $result ) { $result = get_post( $result ); @@ -1991,7 +1997,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo $result = ''; } - wp_cache_set( $query_key, $result, 'counts' ); + wp_cache_set( $cache_key, $result, 'posts' ); if ( $result ) { $result = get_post( $result ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 94231f4f5b..240001569e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55084'; +$wp_version = '6.2-alpha-55085'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.