);
}
+ // Convert startid/endid to timestamps (T163532)
+ if ( $params['startid'] !== null || $params['endid'] !== null ) {
+ $ids = [
+ (int)$params['startid'] => true,
+ (int)$params['endid'] => true,
+ ];
+ unset( $ids[0] ); // null
+ $ids = array_keys( $ids );
+
+ $db = $this->getDB();
+ $sql = $db->unionQueries( [
+ $db->selectSQLText(
+ 'revision',
+ [ 'id' => 'rev_id', 'ts' => 'rev_timestamp' ],
+ [ 'rev_id' => $ids ],
+ __METHOD__
+ ),
+ $db->selectSQLText(
+ 'archive',
+ [ 'id' => 'ar_rev_id', 'ts' => 'ar_timestamp' ],
+ [ 'ar_rev_id' => $ids ],
+ __METHOD__
+ ),
+ ], false );
+ $res = $db->query( $sql, __METHOD__ );
+ foreach ( $res as $row ) {
+ if ( (int)$row->id === (int)$params['startid'] ) {
+ $params['start'] = $row->ts;
+ }
+ if ( (int)$row->id === (int)$params['endid'] ) {
+ $params['end'] = $row->ts;
+ }
+ }
+ if ( $params['startid'] !== null && $params['start'] === null ) {
+ $p = $this->encodeParamName( 'startid' );
+ $this->dieWithError( [ 'apierror-revisions-badid', $p ], "badid_$p" );
+ }
+ if ( $params['endid'] !== null && $params['end'] === null ) {
+ $p = $this->encodeParamName( 'endid' );
+ $this->dieWithError( [ 'apierror-revisions-badid', $p ], "badid_$p" );
+ }
+ }
+
$this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
$params['start'], $params['end'] );
- $this->addWhereRange( 'rev_id', $params['dir'],
- $params['startid'], $params['endid'] );
+ // Dummy to add rev_id to ORDER BY
+ $this->addWhereRange( 'rev_id', $params['dir'], null, null );
// There is only one ID, use it
$ids = array_keys( $pageSet->getGoodTitles() );
"apihelp-query+revisions-description": "Get revision information.\n\nMay be used in several ways:\n# Get data about a set of pages (last revision), by setting titles or pageids.\n# Get revisions for one given page, by using titles or pageids with start, end, or limit.\n# Get data about a set of revisions by setting their IDs with revids.",
"apihelp-query+revisions-paraminfo-singlepageonly": "May only be used with a single page (mode #2).",
- "apihelp-query+revisions-param-startid": "From which revision ID to start enumeration.",
- "apihelp-query+revisions-param-endid": "Stop revision enumeration on this revision ID.",
+ "apihelp-query+revisions-param-startid": "Start enumeration from this revision's timestamp. The revision must exist, but need not belong to this page.",
+ "apihelp-query+revisions-param-endid": "Stop enumeration at this revision's timestamp. The revision must exist, but need not belong to this page.",
"apihelp-query+revisions-param-start": "From which revision timestamp to start enumeration.",
"apihelp-query+revisions-param-end": "Enumerate up to this timestamp.",
"apihelp-query+revisions-param-user": "Only include revisions made by user.",
"apierror-revdel-mutuallyexclusive": "The same field cannot be used in both <var>hide</var> and <var>show</var>.",
"apierror-revdel-needtarget": "A target title is required for this RevDel type.",
"apierror-revdel-paramneeded": "At least one value is required for <var>hide</var> and/or <var>show</var>.",
+ "apierror-revisions-badid": "No revision was found for parameter <var>$1</var>.",
"apierror-revisions-norevids": "The <var>revids</var> parameter may not be used with the list options (<var>$1limit</var>, <var>$1startid</var>, <var>$1endid</var>, <kbd>$1dir=newer</kbd>, <var>$1user</var>, <var>$1excludeuser</var>, <var>$1start</var>, and <var>$1end</var>).",
"apierror-revisions-singlepage": "<var>titles</var>, <var>pageids</var> or a generator was used to supply multiple pages, but the <var>$1limit</var>, <var>$1startid</var>, <var>$1endid</var>, <kbd>$1dir=newer</kbd>, <var>$1user</var>, <var>$1excludeuser</var>, <var>$1start</var>, and <var>$1end</var> parameters may only be used on a single page.",
"apierror-revwrongpage": "r$1 is not a revision of $2.",
"apierror-revdel-mutuallyexclusive": "{{doc-apierror}}",
"apierror-revdel-needtarget": "{{doc-apierror}}",
"apierror-revdel-paramneeded": "{{doc-apierror}}",
+ "apierror-revisions-badid": "{{doc-apierror}}\n\nParameters:\n* $1 - Parameter in question, e.g. \"rvstartid\".",
"apierror-revisions-norevids": "{{doc-apierror}}\n\nParameters:\n* $1 - Module parameter prefix, e.g. \"bl\".",
"apierror-revisions-singlepage": "{{doc-apierror}}\n\nParameters:\n* $1 - Module parameter prefix, e.g. \"bl\".",
"apierror-revwrongpage": "{{doc-apierror}}\n\nParameters:\n* $1 - Revision ID number.\n* $2 - Page title.",