From 487d65ad783776d1ca5d6835eb70b15024b96d08 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 13 Feb 2015 16:59:51 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@31452 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/general-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 15ec1e4396..02e45d52fd 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -1483,7 +1483,7 @@ function wp_get_archives( $args = '' ) { } } } 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"; $key = md5( $query ); $key = "wp_get_archives:$key:$last_changed";