(bug 38904) prop=revisions&rvstart=... should not blow up when continuing
authorBrad Jorsch <anomie.wikipedia@gmail.com>
Wed, 1 Aug 2012 02:45:13 +0000 (22:45 -0400)
committerCatrope <roan.kattouw@gmail.com>
Thu, 2 Aug 2012 21:47:02 +0000 (14:47 -0700)
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
includes/api/ApiQueryRevisions.php

index 727887f..9e17daf 100644 (file)
@@ -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 ===
 
index 7ef90fb..18a6cd4 100644 (file)
@@ -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 {