WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 9 months ago

Last modified 9 months 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:

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

Download all attachments as: .zip

Change History (9)

comment:1 a.hoereth9 months ago

  • Cc a.hoereth@… added

nacin9 months ago

ocean909 months ago

fixes typo

comment:2 ocean909 months 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.

nacin9 months ago

comment:3 nacin9 months 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.

comment:4 markjaquith9 months ago

I'm good with this.

comment:5 nacin9 months 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.

comment:6 nacin9 months 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.