Make WordPress Core


Ignore:
Timestamp:
02/13/2015 04:59:51 PM (10 years ago)
Author:
boonebgorges
Message:

Provide a secondary sort order for wp_get_archives() when type=postbypost.

Sorting by post_date alone can cause indeterminacy problems on different
versions of MySQL when post_date ties need to be broken. Using ID as a
secondary sort ensures that the order is always determinate.

Props herbmillerjr for an initial patch.
Fixes #30480.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r31432 r31452  
    14841484        }
    14851485    } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) {
    1486         $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC ';
     1486        $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
    14871487        $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
    14881488        $key = md5( $query );
Note: See TracChangeset for help on using the changeset viewer.