[wp-trac] [WordPress Trac] #26042: wp_save_post_revision() can compare against the wrong $last_revision post

WordPress Trac noreply at wordpress.org
Fri Nov 15 04:30:59 UTC 2013


#26042: wp_save_post_revision() can compare against the wrong $last_revision post
----------------------------+-----------------------------
 Reporter:  wonderboymusic  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Revisions       |    Version:
 Severity:  normal          |   Keywords:  has-patch
----------------------------+-----------------------------
 There is a unit test that now consistently fails:
 `Tests_Post_Revisions::test_revision_dont_save_revision_if_unchanged()`.
 After some substantial debugging, I have determined that ordering post
 revisions by `post_date DESC` is completely unreliable when posts are
 added within seconds or milliseconds of each other, even when `post_date`
 is explicitly set to increment on `wp_update_post()` because the revisions
 still occur with milliseconds of each other, regardless of what the post's
 `post_date` is.

 When all revisions occur in nearly unison, ordering becomes moot. Sometime
 the revisions return `DESC`. Sometimes they awesomely return in `ASC`
 order, which makes `the $last_revision` that `$post` is compared against
 the first revision.

 The only way to combat this is to sort in `wp_get_post_revisions()` by `ID
 DESC`. All of the unit tests pass with this change. Is there any reason we
 can't rely on sequential posts `DESC` for ordering?

--
Ticket URL: <http://core.trac.wordpress.org/ticket/26042>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list