fix merge of Iec98e472
[lhc/web/wiklou.git] / includes / api / ApiQueryRevisions.php
index 0bb0d77..d6b556d 100644 (file)
@@ -253,6 +253,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.
@@ -362,14 +372,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 {
@@ -540,7 +550,8 @@ class ApiQueryRevisions extends ApiQueryBase {
                                        $model = $content->getModel();
                                        $name = $title->getPrefixedDBkey();
 
-                                       $this->dieUsage( "The requested format {$this->contentFormat} is not supported for content model $model used by $name", 'badformat' );
+                                       $this->dieUsage( "The requested format {$this->contentFormat} is not supported ".
+                                                                       "for content model $model used by $name", 'badformat' );
                                }
 
                                $text = $content->serialize( $format );
@@ -561,15 +572,18 @@ class ApiQueryRevisions extends ApiQueryBase {
                                $vals['diff'] = array();
                                $context = new DerivativeContext( $this->getContext() );
                                $context->setTitle( $title );
-                               $handler = ContentHandler::getForTitle( $title );
+                               $handler = $revision->getContentHandler();
 
                                if ( !is_null( $this->difftotext ) ) {
                                        $model = $title->getContentModel();
 
-                                       if ( $this->contentFormat && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) {
+                                       if ( $this->contentFormat
+                                               && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) {
+
                                                $name = $title->getPrefixedDBkey();
 
-                                               $this->dieUsage( "The requested format {$this->contentFormat} is not supported for content model $model used by $name", 'badformat' );
+                                               $this->dieUsage( "The requested format {$this->contentFormat} is not supported for ".
+                                                                                       "content model $model used by $name", 'badformat' );
                                        }
 
                                        $difftocontent = ContentHandler::makeContent( $this->difftotext, $title, $model, $this->contentFormat );
@@ -598,7 +612,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                        return 'private';
                }
                if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
-                       // formatComment() calls wfMsg() among other things
+                       // formatComment() calls wfMessage() among other things
                        return 'anon-public-user-private';
                }
                return 'public';
@@ -789,14 +803,18 @@ class ApiQueryRevisions extends ApiQueryBase {
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'nosuchrevid', 'diffto' ),
-                       array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).' ),
-                       array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.' ),
+                       array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options '
+                                                                                                       . '(limit, startid, endid, dirNewer, start, end).' ),
+                       array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, '
+                                                                                                       . ' but the limit, startid, endid, dirNewer, user, excludeuser, '
+                                                                                                       . 'start and end parameters may only be used on a single page.' ),
                        array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ),
                        array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
                        array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
                        array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
                        array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ),
-                       array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to the page\'s content model' ),
+                       array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied '
+                                                                                                       . ' to the page\'s content model' ),
                ) );
        }