From 7a657188a1f436c218db754120d2c9e8437361b4 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 31 Jul 2012 22:45:13 -0400 Subject: [PATCH] (bug 38904) prop=revisions&rvstart=... should not blow up when continuing A query using prop=revisions in enum mode will return a query-continue using rvstartid. If the original query included rvstart, the client will therefore send both the rvstart from the original query and the rvstartid from the query-continue. And the API will then return an error that rvstart and rvstartid may not both be used in the same query. Since there is no way for the API to instruct the client to ''not'' send the rvstart when continuing, we'll just use rvcontinue instead. Then the module can ignore both rvstart and rvstartid to get the intended continuation. Change-Id: I145215996b8a7818196cdfb583a1fdacae973fee --- RELEASE-NOTES-1.20 | 1 + includes/api/ApiQueryRevisions.php | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 727887fe8d..9e17daf12a 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -221,6 +221,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * (bug 27610) Add archivename for non-latest image version to list=filearchive * (bug 38231) Add xml parse tree to action=parse. * Watchlist notification timestamp may be queried by page and may be updated via the API. +* (bug 38904) prop=revisions&rvstart=... no longer blows up when continuing. === Languages updated in 1.20 === diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 7ef90fbc33..18a6cd419a 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -248,6 +248,16 @@ class ApiQueryRevisions extends ApiQueryBase { $this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' ); } + // Continuing effectively uses startid. But we can't use rvstartid + // directly, because there is no way to tell the client to ''not'' + // send rvstart if it sent it in the original query. So instead we + // send the continuation startid as rvcontinue, and ignore both + // rvstart and rvstartid when that is supplied. + if ( !is_null( $params['continue'] ) ) { + $params['startid'] = $params['continue']; + unset( $params['start'] ); + } + // 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. @@ -357,14 +367,14 @@ class ApiQueryRevisions extends ApiQueryBase { if ( !$enumRevMode ) { ApiBase::dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report } - $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) ); + $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) ); break; } $fit = $this->addPageSubItem( $row->rev_page, $this->extractRowInfo( $row ), 'rev' ); if ( !$fit ) { if ( $enumRevMode ) { - $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) ); + $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) ); } elseif ( $revCount > 0 ) { $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) ); } else { -- 2.20.1