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.
Built from https://develop.svn.wordpress.org/trunk@31452


git-svn-id: http://core.svn.wordpress.org/trunk@31433 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-02-13 17:00:27 +00:00
parent 6505278ea7
commit 48a5bbf8a7
2 changed files with 2 additions and 2 deletions

View File

@ -1483,7 +1483,7 @@ function wp_get_archives( $args = '' ) {
} }
} }
} elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) { } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) {
$orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC '; $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
$key = md5( $query ); $key = md5( $query );
$key = "wp_get_archives:$key:$last_changed"; $key = "wp_get_archives:$key:$last_changed";

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.2-alpha-31451'; $wp_version = '4.2-alpha-31452';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.