Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#26577 closed defect (bug) (wontfix)

Unable to compare post with single revision

Reported by: bamadesigner Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6
Component: Revisions Keywords: has-patch
Focuses: Cc:


If your post type supports 'revisions', the "Revisions" meta box, and the revisions section of the "Publish" meta box, are only added to your edit post screen if you have more than one revision.

But what if you only have one revision that you want to view/compare? Shouldn't the logic be "if ( count( $revisions ) >= 1 )"?

The logic is on line 128 of the wp-admin/edit-form-advanced.php file.

Here's the code starting with line 124:

if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
	$revisions = wp_get_post_revisions( $post_ID );

	// We should aim to show the revisions metabox only when there are revisions.
	if ( count( $revisions ) > 1 ) {
		reset( $revisions ); // Reset pointer for key()
		$publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) );
		add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');

Attachments (1)

revision-meta-26577.patch (696 bytes) - added by devesine 4 years ago.

Download all attachments as: .zip

Change History (5)

#1 follow-up: @SergeyBiryukov
4 years ago

  • Version changed from 3.8 to 3.6

#2 in reply to: ↑ 1 @devesine
4 years ago

  • Keywords has-patch added

This is a slightly difficult situation, because in the situation where an auto-draft has been created, saving the post in the admin for the first time will create a revision - but if the post is created without an auto-draft (being created automatically by some means, or simply being created too quickly for the auto-draft functionality to kick in), the first change to the post will also create the first revision - which will then cause the revision UI not to display, despite the fact that there is a revision available.

(This also happens if you restrict the number of revisions to 1, it appears.)

My personal feeling (since I ran into this situation with the revision UI not displaying despite a revision being present) is that it's slightly better, absent a more subtle handling of auto-draft to real post causing revisions, to display the revision UI if there are any revisions at all, not just more than one; attached patch does so.

#3 @adamsilverstein
4 years ago

leaving aside the auto-draft for now, the single revision is always the same as the current post, so there would be nothing to show on the revisions screen even if you could go there - it would just show the content of the post as all new 'added' content. as soon as you save any changes to the post there will be two revisions and you can go back to compare what changed in each.

#4 @adamsilverstein
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

With only one revision, the stored post content matches the stored revision; linking to the revisions screen would be useless as far as I can tell.

Note: See TracTickets for help on using tickets.