Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#24782 closed defect (bug) (fixed)

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

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

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 11 years ago.
24782.2.diff (1.1 KB) - added by ocean90 11 years ago.
fixes typo
24782.3.diff (1.3 KB) - added by nacin 11 years ago.

Download all attachments as: .zip

Change History (9)

#1 @a.hoereth
11 years ago

  • Cc a.hoereth@… added

@nacin
11 years ago

@ocean90
11 years ago

fixes typo

#2 @ocean90
11 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
11 years ago

#3 @nacin
11 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
11 years ago

I'm good with this.

#5 @nacin
11 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
11 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.