Ticket #26937: 26937.7.patch
| File 26937.7.patch, 4.7 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/link-template.php
1273 1273 * @return mixed Post object on success. False if no adjacent post exists. Null on failure. 1274 1274 */ 1275 1275 protected function get_post( $args ) { 1276 $this->current_post = get_post( $args['post'] );1276 $this->current_post = get_post( $args['post'] ); 1277 1277 $this->excluded_terms = array_map( 'intval', $args['excluded_terms'] ); 1278 1278 $this->adjacent = $args['previous'] ? 'previous' : 'next'; 1279 1279 $this->taxonomy = $args['taxonomy']; … … 1291 1291 1292 1292 // Build our arguments for WP_Query. 1293 1293 $query_args = array( 1294 'posts_per_page' => 1, 1295 'post_status' => 'publish', 1296 'post_type' => 'post', 1297 'orderby' => 'date', 1298 'order' => 'previous' === $this->adjacent ? 'DESC' : 'ASC', 1299 'no_found_rows' => true, 1300 'cache_results' => true, 1301 'date_query' => array(), 1294 'posts_per_page' => 1, 1295 'post_status' => 'publish', 1296 'post_type' => 'post', 1297 'orderby' => 'date', 1298 'order' => 'previous' === $this->adjacent ? 'DESC' : 'ASC', 1299 'ignore_sticky_posts' => true, 1300 'date_query' => array(), 1301 1302 // Performance considerations: 1303 'no_found_rows' => true, 1304 'cache_results' => true, 1305 'update_post_term_cache' => false, 1306 'update_post_meta_cache' => false, 1307 'split_the_query' => wp_using_ext_object_cache(), 1302 1308 ); 1303 1309 1304 1310 $tax_query = array(); … … 1388 1394 */ 1389 1395 remove_filter( 'posts_clauses', array( $this, 'filter' ) ); 1390 1396 1397 /** 1398 * Posts table must be aliased as `p` for backwards compatibility with query previously generated by `get_adjacent_post()`. 1399 */ 1400 $clauses = array_map( array( $this, 'alias_posts_table' ), $clauses ); 1401 1391 1402 /* 1392 1403 * The `join` and `where` filters are identical in their parameters, 1393 1404 * so we can use the same approach for both. … … 1398 1409 } 1399 1410 } 1400 1411 1412 /** 1413 * Posts table must be aliased as `p` for backwards compatibility with query previously generated by `get_adjacent_post()`. 1414 * No filter on the table name exists, so we have to leverage the next applied filter, that for the join clause. 1415 */ 1416 $clauses['join'] = 'AS p ' . $clauses['join']; 1417 1401 1418 /* 1402 1419 * The legacy `sort` filter combined the ORDER BY and LIMIT clauses, 1403 1420 * while `WP_Query` does not, which requires special handling. … … 1411 1428 } 1412 1429 1413 1430 /** 1431 * Alias posts table as `p` to match query previously built by `get_adjacent_post()` 1432 * 1433 * @global $wpdb 1434 * @param string Clause to alias 1435 * @return string 1436 */ 1437 protected function alias_posts_table( $clause ) { 1438 global $wpdb; 1439 1440 return str_replace( $wpdb->posts, 'p', $clause ); 1441 } 1442 1443 /** 1414 1444 * Apply the deprecated `join` or `where` clause filter to the clauses built by WP_Query. 1415 1445 * 1416 1446 * @param string $value -
src/wp-includes/load.php
377 377 $current_using = $_wp_using_ext_object_cache; 378 378 if ( null !== $using ) 379 379 $_wp_using_ext_object_cache = $using; 380 return $current_using;380 return (bool) $current_using; 381 381 } 382 382 383 383 /** -
src/wp-includes/query.php
3221 3221 } 3222 3222 3223 3223 $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 ); 3224 if ( $split_the_query && isset( $q['split_the_query'] ) && empty( $q['split_the_query'] ) ) { 3225 $split_the_query = false; 3226 } 3224 3227 3225 3228 /** 3226 3229 * Filter whether to split the query. -
tests/phpunit/tests/link.php
251 251 function filter_next_post_join( $join ) { 252 252 global $wpdb; 253 253 254 $join .= " INNER JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id";254 $join .= " INNER JOIN {$wpdb->postmeta} ON p.ID = {$wpdb->postmeta}.post_id"; 255 255 return $join; 256 256 } 257 257 … … 269 269 * Filter callback for `test_legacy_get_adjacent_post_filters()` 270 270 */ 271 271 function filter_next_post_sort( $sort ) { 272 global $wpdb; 273 274 $sort = str_replace( $wpdb->posts . '.post_date', $wpdb->posts . '.post_title', $sort ); 275 return $sort; 272 return str_replace( 'p.post_date', 'p.post_title', $sort ); 276 273 } 277 274 278 275 /**