Ticket #32651: 32651.diff
| File 32651.diff, 2.7 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/link-template.php
1636 1636 } 1637 1637 1638 1638 $adjacent = $previous ? 'previous' : 'next'; 1639 $op = $previous ? '<' : '>'; 1639 $date_compare = $previous ? '<=' : '>='; 1640 $id_compare = '!='; 1640 1641 $order = $previous ? 'DESC' : 'ASC'; 1641 1642 1642 1643 /** … … 1683 1684 * @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true. 1684 1685 * @param WP_Post $post WP_Post object. 1685 1686 */ 1686 $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type ), $in_same_term, $excluded_terms, $taxonomy, $post ); 1687 1687 $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $date_compare %s AND p.ID $id_compare %d AND p.post_type = %s $where", $current_post_date, $post->ID, $post->post_type ), $in_same_term, $excluded_terms, $taxonomy, $post ); 1688 1688 /** 1689 1689 * Filter the ORDER BY clause in the SQL for an adjacent post query. 1690 1690 * … … 1697 1697 * @param string $order_by The `ORDER BY` clause in the SQL. 1698 1698 * @param WP_Post $post WP_Post object. 1699 1699 */ 1700 $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post);1700 $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order, p.ID $order LIMIT 1" ); 1701 1701 1702 1702 $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; 1703 1703 $query_key = 'adjacent_post_' . md5( $query ); -
tests/phpunit/tests/link.php
310 310 $this->assertEquals( $p3, $found->ID ); 311 311 } 312 312 313 /** 314 * @ticket 32651 315 */ 316 function test_get_adjacent_post_same_date_time() { 317 $one = $this->factory->post->create_and_get( array( 318 'post_date' => '2012-01-01 12:00:00', 319 ) ); 320 321 $two = $this->factory->post->create_and_get( array( 322 'post_date' => '2012-01-01 12:00:00', 323 ) ); 324 325 $three = $this->factory->post->create_and_get( array( 326 'post_date' => '2012-01-01 12:00:00', 327 ) ); 328 329 $this->go_to( get_permalink( $two ) ); 330 331 $this->assertEquals( $three, get_adjacent_post( false, array(), false ) ); 332 $this->assertEquals( $one, get_adjacent_post( false, array(), true ) ); 333 } 334 313 335 public function test_wp_make_link_relative_with_http_scheme() { 314 336 $link = 'http://example.com/this-is-a-test-http-url/'; 315 337 $relative_link = wp_make_link_relative( $link );