WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#24782 closed defect (bug) (fixed)

Revisions: Re-think the way how the current revision is detected

Reported by: ocean90 Owned by: nacin
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.6
Component: Revisions Keywords: has-patch commit 2nd-opinion
Focuses: Cc:
PR Number:

Description

To detect if a revision is the current one we do $revision->post_modified_gmt === $post->post_modified_gmt, see trunk/wp-admin/includes/revision.php:24708#L102.

This can be an issue if you are using the API and creating revisions programmatically which can result in same timestamps, since we doesn't save milliseconds, only seconds.

We noticed this while the GSoC project "Code revisions", see #gsoc326 and on make/core.

Not sure if we can do something here, but want to make it known.

Attachments (3)

24782.diff (1.1 KB) - added by nacin 6 years ago.
24782.2.diff (1.1 KB) - added by ocean90 6 years ago.
fixes typo
24782.3.diff (1.3 KB) - added by nacin 6 years ago.

Download all attachments as: .zip

Change History (9)

#1 @a.hoereth
6 years ago

  • Cc a.hoereth@… added

@nacin
6 years ago

@ocean90
6 years ago

fixes typo

#2 @ocean90
6 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.6
  • Version set to trunk

24782.2.diff works for me. Tested with Code Revisions and some test posts. Works also with an autosave as latest revision.

@nacin
6 years ago

#3 @nacin
6 years ago

  • Keywords commit 2nd-opinion added; dev-feedback removed

Works also with an autosave as latest revision.

24782.3.diff tries to make absolutely sure that an autosave will not accidentally be considered to be the current revision. Some odd set of closely timed events, I guess, could cause this.

#4 @markjaquith
6 years ago

I'm good with this.

#5 @nacin
6 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 24730:

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.

#6 @nacin
6 years ago

Note:

	// If a post has been saved since the last revision (no revisioned fields were changed)
	// we may not have a "current" revision. Mark the latest revision as "current".
	if ( empty( $current_id ) )
		$revisions[ $revision->ID ]['current'] = true;

... being added in #24804 (first appearance is .9.diff).

Note: See TracTickets for help on using tickets.