[wp-trac] [WordPress Trac] #24425: Revisions cleanup

WordPress Trac noreply at wordpress.org
Tue Jul 9 11:12:50 UTC 2013


#24425: Revisions cleanup
----------------------------+--------------------
 Reporter:  markjaquith     |       Owner:
     Type:  task (blessed)  |      Status:  new
 Priority:  high            |   Milestone:  3.6
Component:  Revisions       |     Version:  trunk
 Severity:  blocker         |  Resolution:
 Keywords:                  |
----------------------------+--------------------

Comment (by duck_):

 [24520] made the comparator for the Revisions collection to be the
 revision's ID. This is incorrect behaviour since autosaves are
 overwritten. This means that an autosave may have a lower ID than some
 revisions, but contain newer content.

 Instead the comparator should be date based, e.g.

 {{{
 comparator: function( a, b ) {
     var a_ = new Date(a.get("date")),
         b_ = new Date(b.get("date"));
     var cmp = (a_ > b_) - (a_ < b_);
     if (cmp == 0 && a.id != b.id)
         cmp = a.id < b.id ? -1 : 1;
     return cmp;
 },
 }}}

 Issues with this quick hack are that it doesn't compare down to the second
 so falling back on the ID may not be enough in some circumstances, it
 should be tested for cross-browser equality of date parsing (the date
 property contains an "@" character), and it's not very clear. Maybe it
 would be better to have a unix timestamp in the model for comparision.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/24425#comment:42>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list