+ // This code makes an assumption that sorting by rev_id and rev_timestamp produces
+ // the same result. This way users may request revisions starting at a given time,
+ // but to page through results use the rev_id returned after each page.
+ // Switching to rev_id removes the potential problem of having more than
+ // one row with the same timestamp for the same page.
+ // The order needs to be the same as start parameter to avoid SQL filesort.
+ $options['ORDER BY'] = ($rvstartid !== 0 ? 'rev_id' : 'rev_timestamp') . ($dirNewer ? '' : ' DESC');
+