Merge "(bug 26585) Detect CSV/array values in $_SERVER['REMOTE_ADDR']."
[lhc/web/wiklou.git] / includes / api / ApiQueryRevisions.php
index 2c0bf1f..881b797 100644 (file)
@@ -196,8 +196,9 @@ class ApiQueryRevisions extends ApiQueryBase {
 
                if ( isset( $prop['content'] ) || !is_null( $this->difftotext ) ) {
                        // For each page we will request, the user must have read rights for that page
+                       $user = $this->getUser();
                        foreach ( $pageSet->getGoodTitles() as $title ) {
-                               if ( !$title->userCan( 'read' ) ) {
+                               if ( !$title->userCan( 'read', $user ) ) {
                                        $this->dieUsage(
                                                'The current user is not allowed to read ' . $title->getPrefixedText(),
                                                'accessdenied' );
@@ -539,7 +540,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                                }
                        }
                        if ( $this->parseContent ) {
-                               $po = $content->getParserOutput( $title, ParserOptions::newFromContext( $this->getContext() ) );
+                               $po = $content->getParserOutput( $title, $revision->getId(), ParserOptions::newFromContext( $this->getContext() ) );
                                $text = $po->getText();
                        }
 
@@ -550,7 +551,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 );
@@ -571,15 +573,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 );
@@ -608,7 +613,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';
@@ -799,14 +804,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' ),
                ) );
        }