Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#24782 closed defect (bug) (fixed)

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

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

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

Download all attachments as: .zip

Change History (9)

#1 @a.hoereth
13 years ago

  • Cc a.hoereth@… added

@nacin
13 years ago

@ocean90
13 years ago

fixes typo

#2 @ocean90
13 years ago

  • Keywords has-patch added
  • Milestone Awaiting Review3.6
  • Versiontrunk

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

@nacin
13 years ago

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

I'm good with this.

#5 @nacin
13 years ago

  • Owner set to nacin
  • Resolutionfixed
  • Status newclosed

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
13 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.