Make WordPress Core

Ticket #37489: 37489.patch

File 37489.patch, 1.8 KB (added by Toro_Unit, 9 years ago)
  • src/wp-includes/query.php

     
    30183018                        }
    30193019                }
    30203020
     3021                if ( ! empty( $orderby ) and $orderby == "$wpdb->posts.post_date " . $q['order'] ) {
     3022                        $orderby = "$wpdb->posts.post_date " . $q['order'].  ", $wpdb->posts.ID " . $q['order'];
     3023                }
     3024
    30213025                // Order search results by relevance only when another "orderby" is not specified in the query.
    30223026                if ( ! empty( $q['s'] ) ) {
    30233027                        $search_orderby = '';
  • tests/phpunit/tests/post/getPosts.php

     
    125125
    126126                $this->assertSame( array( $p3 ), $found );
    127127        }
     128
    128129}
  • tests/phpunit/tests/query/results.php

     
    718718                $feed_comment = $this->q->next_comment();
    719719                $this->assertEquals( $comment_id, $feed_comment->comment_ID );
    720720        }
     721
     722
     723        public function test_posts_order_for_same_date() {
     724                $this->factory->post->create_many( 100, array(
     725                        'post_date' => '2016-01-01 00:00:00'
     726                ) );
     727
     728                $expected = array_map( array( $this, 'get_post_id' ), $this->q->query( array() ) );
     729                $actual   = array_map( array( $this, 'get_post_id' ), $this->q->query( array(
     730                        'post_status' => array(
     731                                'private',
     732                                'publish'
     733                        )
     734                ) ) );
     735                $this->assertSame( $expected, $actual );
     736
     737        }
     738
     739        /**
     740         * @param WP_Post $post
     741         * @return int
     742         */
     743        public function get_post_id( $post ) {
     744                return $post->ID;
     745        }
    721746}