<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[27836] trunk: Revert the conversion of adjacent post queries to WP_Query.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/27836">27836</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2014-03-29 06:02:01 +0000 (Sat, 29 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Revert the conversion of adjacent post queries to WP_Query. Explanation on the ticket.
Reverts <a href="http://core.trac.wordpress.org/changeset/27285">[27285]</a>, <a href="http://core.trac.wordpress.org/changeset/27286">[27286]</a>, <a href="http://core.trac.wordpress.org/changeset/27287">[27287]</a>, <a href="http://core.trac.wordpress.org/changeset/27288">[27288]</a>, <a href="http://core.trac.wordpress.org/changeset/27291">[27291]</a>, <a href="http://core.trac.wordpress.org/changeset/27292">[27292]</a>, <a href="http://core.trac.wordpress.org/changeset/27293">[27293]</a>, <a href="http://core.trac.wordpress.org/changeset/27296">[27296]</a>, <a href="http://core.trac.wordpress.org/changeset/27633">[27633]</a>, <a href="http://core.trac.wordpress.org/changeset/27634">[27634]</a>, <a href="http://core.trac.wordpress.org/changeset/27635">[27635]</a>, and <a href="http://core.trac.wordpress.org/changeset/27692">[27692]</a>.
see <a href="http://core.trac.wordpress.org/ticket/26937">#26937</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludeslinktemplatephp">trunk/src/wp-includes/link-template.php</a></li>
<li><a href="#trunksrcwpincludesloadphp">trunk/src/wp-includes/load.php</a></li>
<li><a href="#trunksrcwpincludesqueryphp">trunk/src/wp-includes/query.php</a></li>
<li><a href="#trunktestsphpunittestslinkphp">trunk/tests/phpunit/tests/link.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/link-template.php (27835 => 27836)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/link-template.php 2014-03-29 05:17:57 UTC (rev 27835)
+++ trunk/src/wp-includes/link-template.php 2014-03-29 06:02:01 UTC (rev 27836)
</span><span class="lines">@@ -1133,423 +1133,82 @@
</span><span class="cx"> * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
</span><span class="cx"> * @param bool $previous Optional. Whether to retrieve previous post.
</span><span class="cx"> * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
</span><del>- * @return mixed Post object if successful. Null if current post doesn't exist. Empty string if no corresponding adjacent post exists.
</del><ins>+ * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
</ins><span class="cx"> */
</span><span class="cx"> function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
</span><del>- if ( is_string( $excluded_terms ) && false !== strpos( $excluded_terms, ' and ' ) ) {
- // back-compat: $excluded_terms used to be IDs separated by " and "
- _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
- $excluded_terms = explode( ' and ', $excluded_terms );
- }
- if ( $excluded_terms ) {
- $excluded_terms = wp_parse_id_list( $excluded_terms );
- } else {
- $excluded_terms = array();
- }
</del><ins>+ global $wpdb;
</ins><span class="cx">
</span><del>- $adjacent = new WP_Adjacent_Post( array(
- 'post' => get_post(),
- 'previous' => $previous,
- 'taxonomy' => $taxonomy,
- 'in_same_term' => $in_same_term,
- 'excluded_terms' => $excluded_terms,
- ) );
</del><ins>+ if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) )
+ return null;
</ins><span class="cx">
</span><del>- return $adjacent->adjacent_post;
-}
</del><ins>+ $current_post_date = $post->post_date;
</ins><span class="cx">
</span><del>-/**
- * WordPress Adjacent Post API
- *
- * Based on the current or specified post, determines either the previous or
- * next post based on the criteria specified. Supports retrieving posts with
- * the same taxonomy terms and posts that lack specific terms.
- *
- * @since 3.9.0
- *
- * @package WordPress
- * @subpackage Template
- */
-class WP_Adjacent_Post {
</del><ins>+ $join = '';
+ $posts_in_ex_terms_sql = '';
+ 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";
</ins><span class="cx">
</span><del>- /**
- * Adjacent post object.
- *
- * @since 3.9.0
- * @access public
- * @var null|WP_Adjacent_Post
- */
- public $adjacent_post = null;
-
- /**
- * Current post object.
- *
- * @since 3.9.0
- * @access protected
- * @var bool|WP_Post
- */
- protected $current_post = false;
-
- /**
- * 'previous' or 'next' type of adjacent post.
- *
- * @since 3.9.0
- * @access protected
- * @var string
- */
- protected $adjacent = 'previous';
-
- /**
- * Post taxonomy.
- *
- * @since 3.9.0
- * @access protected
- * @var string
- */
- protected $taxonomy = 'category';
-
- /**
- * Whether the post should be in a same taxonomy term.
- *
- * @since 3.9.0
- * @access protected
- * @var string
- */
- protected $in_same_term = false;
-
- /**
- * Excluded term IDs.
- *
- * @since 3.9.0
- * @access protected
- * @var string|array
- */
- protected $excluded_terms = '';
-
- /**
- * Class constructor.
- *
- * The post is queried is run if arguments are passed to the constructor.
- * Otherwise, the get_post() method will need to be called.
- *
- * @param array $args Optional. See the get_post() method for $args.
- */
- public function __construct( $args = array() ) {
- if ( empty( $args ) ) {
- return;
</del><ins>+ if ( $in_same_term ) {
+ if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) )
+ return '';
+ $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
+ if ( ! $term_array || is_wp_error( $term_array ) )
+ return '';
+ $join .= $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id IN (" . implode( ',', array_map( 'intval', $term_array ) ) . ")", $taxonomy );
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- $this->get_post( $args );
- }
-
- /**
- * Allow direct access to adjacent post from the class instance itself.
- *
- * @param string $property Property to get.
- * @return mixed String when adjacent post is found and post property exists. Null when no adjacent post is found.
- */
- public function __get( $property ) {
- if ( is_object( $this->adjacent_post ) && property_exists( $this->adjacent_post, $property ) ) {
- return $this->adjacent_post->{$property};
- } else {
- return null;
- }
- }
-
- /**
- * Determine adjacent post for specified post and adjacency.
- *
- * @since 3.9.0
- *
- * @param array $args {
- * Arguments for querying the adjacent post.
- *
- * @type mixed $post Optional. Post object or ID to find adjacent post for.
- * @type bool $previous Optional. Whether to retrieve previous post.
- * @type string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
- * @type bool $in_same_term Optional. Whether post should be in a same taxonomy term.
- * @type array $excluded_terms Optional. Array of excluded term IDs.
- * }
- * @return mixed Post object on success. False if no adjacent post exists. Null on failure.
- */
- protected function get_post( $args ) {
- $this->current_post = get_post( $args['post'] );
- $this->excluded_terms = array_map( 'intval', $args['excluded_terms'] );
- $this->adjacent = $args['previous'] ? 'previous' : 'next';
- $this->taxonomy = $args['taxonomy'];
- $this->in_same_term = (bool) $args['in_same_term'];
-
- // Return null when either the post or taxonomy doesn't exist.
- if ( ! $this->current_post ) {
- return;
- }
- if ( $this->in_same_term || $this->excluded_terms ) {
- if ( ! taxonomy_exists( $args['taxonomy'] ) ) {
- return;
</del><ins>+ $posts_in_ex_terms_sql = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
+ if ( ! empty( $excluded_terms ) ) {
+ if ( ! is_array( $excluded_terms ) ) {
+ // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
+ if ( false !== strpos( $excluded_terms, ' and ' ) ) {
+ _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
+ $excluded_terms = explode( ' and ', $excluded_terms );
+ } else {
+ $excluded_terms = explode( ',', $excluded_terms );
+ }
</ins><span class="cx"> }
</span><del>- }
</del><span class="cx">
</span><del>- // Build our arguments for WP_Query.
- $query_args = array(
- 'posts_per_page' => 1,
- 'post_status' => 'publish',
- 'post_type' => $this->current_post->post_type,
- 'orderby' => 'date',
- 'order' => 'previous' === $this->adjacent ? 'DESC' : 'ASC',
- 'ignore_sticky_posts' => true,
- 'date_query' => array(),
</del><ins>+ $excluded_terms = array_map( 'intval', $excluded_terms );
</ins><span class="cx">
</span><del>- // Performance considerations:
- 'no_found_rows' => true,
- 'cache_results' => true,
- 'update_post_term_cache' => false,
- 'update_post_meta_cache' => false,
- 'split_the_query' => wp_using_ext_object_cache(),
- );
-
- $tax_query = array();
-
- // Set up for requests limited to posts that share terms.
- if ( $this->in_same_term ) {
- $terms = get_the_terms( $this->current_post->ID, $args['taxonomy'] );
-
- if ( is_array( $terms ) && ! empty( $terms ) ) {
- $terms = wp_list_pluck( $terms, 'term_id' );
- $terms = array_values( $terms );
- $terms = array_map( 'intval', $terms );
- } else {
- unset( $terms );
</del><ins>+ if ( ! empty( $term_array ) ) {
+ $excluded_terms = array_diff( $excluded_terms, $term_array );
+ $posts_in_ex_terms_sql = '';
</ins><span class="cx"> }
</span><del>- }
</del><span class="cx">
</span><del>- // Handle excluded terms.
- if ( $this->excluded_terms ) {
- $tax_query[] = array(
- 'taxonomy' => $args['taxonomy'],
- 'slugs' => $this->excluded_terms,
- 'compare' => 'NOT IN',
- );
- }
-
- // If requesting same term, ensure excluded terms don't appear in term list.
- if ( isset( $terms ) ) {
- if ( isset( $this->excluded_terms ) && is_array( $this->excluded_terms ) ) {
- $terms = array_diff( $terms, $this->excluded_terms );
</del><ins>+ if ( ! empty( $excluded_terms ) ) {
+ $posts_in_ex_terms_sql = $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id NOT IN (" . implode( $excluded_terms, ',' ) . ')', $taxonomy );
</ins><span class="cx"> }
</span><del>-
- if ( ! empty( $terms ) ) {
- $tax_query[] = array(
- 'taxonomy' => $args['taxonomy'],
- 'terms' => $terms,
- );
- }
</del><span class="cx"> }
</span><del>-
- // If we have a tax query, add it to our query args.
- if ( $tax_query ) {
- $query_args['tax_query'] = $tax_query;
- }
-
- // And now, the date constraint.
- $date_query_key = 'previous' === $this->adjacent ? 'before' : 'after';
-
- $query_args['date_query'][] = array(
- $date_query_key => $this->current_post->post_date,
- 'inclusive' => true,
- );
-
- // Ensure the current post isn't returned, since we're using an inclusive date query.
- $query_args['post__not_in'] = array( $this->current_post->ID );
-
- /**
- * Filter the arguments passed to WP_Query when finding an adjacent post.
- *
- * @since 3.9.0
- *
- * @param array $query_args WP_Query arguments.
- * @param array $args Arguments passed to WP_Adjacent_Post.
- */
- $query_args = apply_filters( 'get_adjacent_post_query_args', $query_args, $args );
-
- add_filter( 'posts_clauses', array( $this, 'filter' ) );
- $query = new WP_Query( $query_args );
-
- if ( $query->posts ) {
- $this->adjacent_post = $query->post;
- } else {
- $this->adjacent_post = false;
- }
</del><span class="cx"> }
</span><span class="cx">
</span><del>- /**
- * Apply the deprecated filters to WP_Query's clauses.
- *
- * @param array $clauses
- * @return array
- */
- public function filter( $clauses ) {
- /*
- * Immediately deregister these legacy filters to avoid modifying
- * any calls to WP_Query from filter callbacks hooked to WP_Query filters.
- */
- remove_filter( 'posts_clauses', array( $this, 'filter' ) );
</del><ins>+ $adjacent = $previous ? 'previous' : 'next';
+ $op = $previous ? '<' : '>';
+ $order = $previous ? 'DESC' : 'ASC';
</ins><span class="cx">
</span><del>- /**
- * If no legacy filter callbacks are registered, proceed no further.
- */
- if ( ! has_filter( 'get_' . $this->adjacent . '_post_join' ) && ! has_filter( 'get_' . $this->adjacent . '_post_where' ) && ! has_filter( 'get_' . $this->adjacent . '_post_sort' ) ) {
- return $clauses;
- }
</del><ins>+ $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms );
+ $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_terms_sql", $current_post_date, $post->post_type), $in_same_term, $excluded_terms );
+ $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" );
</ins><span class="cx">
</span><del>- /**
- * Posts table must be aliased as `p` for backwards compatibility with query previously generated by `get_adjacent_post()`.
- */
- $clauses = array_map( array( $this, 'alias_posts_table' ), $clauses );
-
- /**
- * Apply the legacy `join` filter.
- */
- if ( has_filter( 'get_' . $this->adjacent . '_post_join' ) ) {
- $clauses['join'] = $this->filter_join( $clauses['join'] );
- }
-
- /**
- * Posts table must be aliased as `p` for backwards compatibility with query previously generated by `get_adjacent_post()`.
- * No filter on the table name exists, so we have to leverage the next applied filter, that for the `join` clause.
- * We wait to apply this until after the legacy filter is applied so that the legacy filter doesn't remove the alias.
- */
- $clauses['join'] = 'AS p ' . $clauses['join'];
-
- /**
- * Apply the legacy `where` filter.
- */
- if ( has_filter( 'get_' . $this->adjacent . '_post_where' ) ) {
- $clauses['where'] = $this->filter_where( $clauses['where'] );
- }
-
- /*
- * The legacy `sort` filter combined the ORDER BY and LIMIT clauses,
- * while `WP_Query` does not, which requires special handling.
- */
- if ( has_filter( 'get_' . $this->adjacent . '_post_sort' ) ) {
- $sort_clauses = $this->filter_sort( $clauses['orderby'], $clauses['limits'] );
- $clauses = array_merge( $clauses, $sort_clauses );
- }
-
- return $clauses;
</del><ins>+ $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' );
+ if ( false !== $result ) {
+ if ( $result )
+ $result = get_post( $result );
+ return $result;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- /**
- * Alias posts table as `p` to match query previously built by `get_adjacent_post()`.
- *
- * @global $wpdb
- * @param string Clause to alias
- * @return string
- */
- protected function alias_posts_table( $clause ) {
- global $wpdb;
</del><ins>+ $result = $wpdb->get_var( $query );
+ if ( null === $result )
+ $result = '';
</ins><span class="cx">
</span><del>- return str_replace( $wpdb->posts, 'p', $clause );
- }
</del><ins>+ wp_cache_set( $query_key, $result, 'counts' );
</ins><span class="cx">
</span><del>- /**
- * Apply the deprecated `join` clause filter to the clause built by WP_Query.
- *
- * @param string $join
- * @return string
- */
- protected function filter_join( $join ) {
- /**
- * @deprecated 3.9.0
- */
- return apply_filters( 'get_' . $this->adjacent . '_post_join', $join, $this->in_same_term, $this->excluded_terms );
- }
</del><ins>+ if ( $result )
+ $result = get_post( $result );
</ins><span class="cx">
</span><del>- /**
- * Apply the deprecated `where` clause filter to the clause built by WP_Query.
- *
- * @param string $join
- * @return string
- */
- protected function filter_where( $where ) {
- $where = trim( $where );
-
- // The legacy filter passed the entire clause, including the `WHERE`, while WP_Query's filter does not.
- // We prepend the `WHERE` for the benefit of legacy callbacks that look for it.
- if ( 0 !== stripos( $where, 'where' ) ) {
- $where = 'WHERE 1=1 ' . $where;
- }
-
- /**
- * @deprecated 3.9.0
- */
- $where = apply_filters( 'get_' . $this->adjacent . '_post_where', $where, $this->in_same_term, $this->excluded_terms );
-
- $where = trim( $where );
-
- // The legacy filter passed the entire clause, including the `WHERE`, while WP_Query's filter does not.
- // Removing the `WHERE` is necessary as we've added it above, and the legacy filter could include it in the returned string.
- if ( 0 === stripos( $where, 'where 1=1' ) ) {
- $where = substr( $where, 9 );
- } elseif ( 0 === stripos( $where, 'where' ) ) {
- $where = substr( $where, 5 );
- }
-
- $where = trim( $where );
-
- // WP_Query expects that the string returned begins with `AND`, as it is prepended with "1=1" when the clauses are joined
- if ( 0 !== stripos( $where, 'and' ) ) {
- $where = 'AND ' . $where;
- }
-
- return $where;
- }
-
- /**
- * Apply deprecated `sort` filter, which applies to both the ORDER BY and LIMIT clauses.
- *
- * @param string $orderby
- * @param string $limits
- * @return array
- */
- protected function filter_sort( $orderby, $limits ) {
- /**
- * @deprecated 3.9.0
- */
- $sort = apply_filters( 'get_' . $this->adjacent . '_post_sort', 'ORDER BY ' . $orderby . ' ' . $limits );
-
- if ( empty( $sort ) ) {
- return compact( 'orderby', 'limits' );
- }
-
- // The legacy filter could allow either clause to be removed, or their order inverted, so we need to know what we have and where.
- $has_order_by = stripos( $sort, 'order by' );
- $has_limit = stripos( $sort, 'limit' );
-
- // Split the string of one or two clauses into their respective array keys
- if ( false !== $has_order_by && false !== $has_limit ) {
- /*
- * The LIMIT clause cannot appear before the ORDER BY clause in a valid query
- * However, since the legacy filter would allow a user to invert the order,
- * we maintain that handling so the same errors are triggered.
- */
- if ( $has_order_by < $has_limit ) {
- $orderby = trim( str_ireplace( 'order by', '', substr( $sort, 0, $has_limit ) ) );
- $limits = trim( substr( $sort, $has_limit ) );
- } else {
- $orderby = trim( str_ireplace( 'order by', '', substr( $sort, $has_order_by ) ) );
- $limits = trim( substr( $sort, 0, $has_order_by ) );
- }
- } elseif ( false !== $has_order_by ) {
- $orderby = trim( str_ireplace( 'order by', '', $sort ) );
- $limits = '';
- } elseif ( false !== $has_limit ) {
- $orderby = '';
- $limits = trim( $sort );
- }
-
- return compact( 'orderby', 'limits' );
- }
</del><ins>+ return $result;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesloadphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/load.php (27835 => 27836)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/load.php 2014-03-29 05:17:57 UTC (rev 27835)
+++ trunk/src/wp-includes/load.php 2014-03-29 06:02:01 UTC (rev 27836)
</span><span class="lines">@@ -377,7 +377,7 @@
</span><span class="cx"> $current_using = $_wp_using_ext_object_cache;
</span><span class="cx"> if ( null !== $using )
</span><span class="cx"> $_wp_using_ext_object_cache = $using;
</span><del>- return (bool) $current_using;
</del><ins>+ return $current_using;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesqueryphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/query.php (27835 => 27836)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/query.php 2014-03-29 05:17:57 UTC (rev 27835)
+++ trunk/src/wp-includes/query.php 2014-03-29 06:02:01 UTC (rev 27836)
</span><span class="lines">@@ -3221,9 +3221,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );
</span><del>- if ( $split_the_query && isset( $q['split_the_query'] ) && empty( $q['split_the_query'] ) ) {
- $split_the_query = false;
- }
</del><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Filter whether to split the query.
</span></span></pre></div>
<a id="trunktestsphpunittestslinkphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/phpunit/tests/link.php (27835 => 27836)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/phpunit/tests/link.php 2014-03-29 05:17:57 UTC (rev 27835)
+++ trunk/tests/phpunit/tests/link.php 2014-03-29 06:02:01 UTC (rev 27836)
</span><span class="lines">@@ -188,150 +188,4 @@
</span><span class="cx"> $this->assertEquals( array( $post_two ), get_boundary_post( true, '', true, 'post_tag' ) );
</span><span class="cx"> $this->assertEquals( array( $post_four ), get_boundary_post( true, '', false, 'post_tag' ) );
</span><span class="cx"> }
</span><del>-
- /**
- * @ticket 26937
- */
- function test_legacy_get_adjacent_post_filters() {
- // Need some sample posts to test adjacency
- $post_one = $this->factory->post->create_and_get( array(
- 'post_title' => 'First',
- 'post_date' => '2012-01-01 12:00:00',
- ) );
-
- $post_two = $this->factory->post->create_and_get( array(
- 'post_title' => 'Second',
- 'post_date' => '2012-02-01 12:00:00',
- ) );
-
- $post_three = $this->factory->post->create_and_get( array(
- 'post_title' => 'Third',
- 'post_date' => '2012-03-01 12:00:00',
- ) );
-
- $post_four = $this->factory->post->create_and_get( array(
- 'post_title' => 'Fourth',
- 'post_date' => '2012-04-01 12:00:00',
- ) );
-
- // Use pages to test post-type adjacency
- $page_one = $this->factory->post->create_and_get( array(
- 'post_title' => 'First Page',
- 'post_date' => '2013-01-01 12:00:00',
- 'post_type' => 'page',
- ) );
-
- $page_two = $this->factory->post->create_and_get( array(
- 'post_title' => 'Second Page',
- 'post_date' => '2013-02-01 12:00:00',
- 'post_type' => 'page',
- ) );
-
- // Add some meta so we can join the postmeta table and query
- add_post_meta( $post_three->ID, 'unit_test_meta', 'waffle' );
-
- // Test "where" filter for a previous post
- add_filter( 'get_previous_post_where', array( $this, 'filter_previous_post_where' ) );
- $this->go_to( get_permalink( $post_three->ID ) );
- $this->assertEquals( $post_one, get_adjacent_post( false, null, true ) );
- remove_filter( 'get_previous_post_where', array( $this, 'filter_previous_post_where' ) );
-
- // Test "where" filter for a next post
- add_filter( 'get_next_post_where', array( $this, 'filter_next_post_where' ) );
- $this->go_to( get_permalink( $post_two->ID ) );
- $this->assertEquals( $post_four, get_adjacent_post( false, null, false ) );
- remove_filter( 'get_next_post_where', array( $this, 'filter_next_post_where' ) );
-
- // Test "where" filter that writes its own query
- add_filter( 'get_previous_post_where', array( $this, 'override_previous_post_where_clause' ) );
- $this->go_to( get_permalink( $post_four->ID ) );
- $this->assertEquals( $post_two, get_adjacent_post( false, null, true ) );
- remove_filter( 'get_previous_post_where', array( $this, 'override_previous_post_where_clause' ) );
-
- // Test "join" filter by joining the postmeta table and restricting by meta key
- add_filter( 'get_next_post_join', array( $this, 'filter_next_post_join' ) );
- add_filter( 'get_next_post_where', array( $this, 'filter_next_post_where_with_join' ) );
- $this->go_to( get_permalink( $post_one->ID ) );
- $this->assertEquals( $post_three, get_adjacent_post( false, null, false ) );
- remove_filter( 'get_next_post_join', array( $this, 'filter_next_post_join' ) );
- remove_filter( 'get_next_post_where', array( $this, 'filter_next_post_where_with_join' ) );
-
- // Test "sort" filter when modifying ORDER BY clause
- add_filter( 'get_next_post_sort', array( $this, 'filter_next_post_sort' ) );
- $this->go_to( get_permalink( $post_one->ID ) );
- $this->assertEquals( $post_four, get_adjacent_post( false, null, false ) );
- remove_filter( 'get_next_post_sort', array( $this, 'filter_next_post_sort' ) );
-
- // Test "sort" filter when modifying LIMIT clause
- add_filter( 'get_next_post_sort', array( $this, 'filter_next_post_sort_limit' ) );
- $this->go_to( get_permalink( $post_one->ID ) );
- $this->assertEquals( $post_three, get_adjacent_post( false, null, false ) );
- remove_filter( 'get_next_post_sort', array( $this, 'filter_next_post_sort_limit' ) );
-
- // Test post-type specificity
- $this->go_to( get_permalink( $page_one ) );
- $this->assertEquals( $page_two, get_adjacent_post( false, null, false ) );
-
- $this->go_to( get_permalink( $page_two ) );
- $this->assertEquals( $page_one, get_adjacent_post( false, null, true ) );
- }
-
- /**
- * Filter callback for `test_legacy_get_adjacent_post_filters()`
- */
- function filter_previous_post_where( $where ) {
- $where .= " AND post_title !='Second'";
- return $where;
- }
-
- /**
- * Filter callback for `test_legacy_get_adjacent_post_filters()`
- */
- function filter_next_post_where( $where ) {
- $where .= " AND post_title !='Third'";
- return $where;
- }
-
- /**
- * Filter callback for `test_legacy_get_adjacent_post_filters()`
- */
- function override_previous_post_where_clause( $where ) {
- $where = "WHERE p.post_date < '2012-02-28'";
- return $where;
- }
-
- /**
- * Filter callback for `test_legacy_get_adjacent_post_filters()`
- */
- function filter_next_post_join( $join ) {
- global $wpdb;
-
- $join .= " INNER JOIN {$wpdb->postmeta} ON p.ID = {$wpdb->postmeta}.post_id";
- return $join;
- }
-
- /**
- * Filter callback for `test_legacy_get_adjacent_post_filters()`
- */
- function filter_next_post_where_with_join( $where ) {
- global $wpdb;
-
- $where .= " AND {$wpdb->postmeta}.meta_key = 'unit_test_meta'";
- return $where;
- }
-
- /**
- * Filter callback for `test_legacy_get_adjacent_post_filters()`
- */
- function filter_next_post_sort( $sort ) {
- return str_replace( 'p.post_date', 'p.post_title', $sort );
- }
-
- /**
- * Filter callback for `test_legacy_get_adjacent_post_filters()`
- */
- function filter_next_post_sort_limit( $sort ) {
- $sort = str_replace( 'LIMIT 0, 1', 'LIMIT 1, 2', $sort );
- return $sort;
- }
</del><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>