If two revisions were created at the same time, mark the one with the greater ID as current. Also avoid flagging autosaves as current. fixes #24782.

git-svn-id: https://develop.svn.wordpress.org/trunk@24730 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-07-18 14:10:33 +00:00
parent ef63a55d8f
commit 387d9cb94c
1 changed files with 15 additions and 2 deletions

View File

@ -116,6 +116,19 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
);
}
$autosave = wp_is_post_autosave( $revision );
$current = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt;
if ( $current && ! empty( $current_id ) ) {
if ( $current_id < $revision->ID ) {
$revisions[ $current_id ]['current'] = false;
$current_id = $revision->ID;
} else {
$current = false;
}
} elseif ( $current ) {
$current_id = $revision->ID;
}
$revisions[ $revision->ID ] = array(
'id' => $revision->ID,
'title' => get_the_title( $post->ID ),
@ -123,8 +136,8 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
'date' => date_i18n( __( 'M j, Y @ G:i' ), $modified ),
'dateShort' => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified ),
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
'autosave' => wp_is_post_autosave( $revision ),
'current' => $revision->post_modified_gmt === $post->post_modified_gmt,
'autosave' => $autosave,
'current' => $current,
'restoreUrl' => urldecode( $restore_link ),
);
}