X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRevisionsBase.php;h=696ec878670c77203eaad7d0ce1a226b91bd3d28;hb=9012dfe523854a125e781d6fb7d255431615d95a;hp=c12393da94d5dbe6e906f92c49bebfa0fea39861;hpb=3071f1fad720f1773864621158a0c59b73124896;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index c12393da94..696ec87867 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -70,10 +70,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { && $params['diffto'] != 'prev' && $params['diffto'] != 'next' ) { $p = $this->getModulePrefix(); - $this->dieUsage( - "{$p}diffto must be set to a non-negative number, \"prev\", \"next\" or \"cur\"", - 'diffto' - ); + $this->dieWithError( [ 'apierror-baddiffto', $p ], 'diffto' ); } // Check whether the revision exists and is readable, // DifferenceEngine returns a rather ambiguous empty @@ -81,10 +78,10 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { if ( $params['diffto'] != 0 ) { $difftoRev = Revision::newFromId( $params['diffto'] ); if ( !$difftoRev ) { - $this->dieUsageMsg( [ 'nosuchrevid', $params['diffto'] ] ); + $this->dieWithError( [ 'apierror-nosuchrevid', $params['diffto'] ] ); } if ( !$difftoRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) { - $this->setWarning( "Couldn't diff to r{$difftoRev->getId()}: content is hidden" ); + $this->addWarning( [ 'apiwarn-difftohidden', $difftoRev->getId() ] ); $params['diffto'] = null; } } @@ -262,8 +259,12 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { if ( $content && $this->section !== false ) { $content = $content->getSection( $this->section, false ); if ( !$content ) { - $this->dieUsage( - "There is no section {$this->section} in r" . $revision->getId(), + $this->dieWithError( + [ + 'apierror-nosuchsection-what', + wfEscapeWikiText( $this->section ), + $this->msg( 'revid', $revision->getId() ) + ], 'nosuchsection' ); } @@ -294,9 +295,14 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { $vals['parsetree'] = $xml; } else { $vals['badcontentformatforparsetree'] = true; - $this->setWarning( "Conversion to XML is supported for wikitext only, " . - $title->getPrefixedDBkey() . - " uses content model " . $content->getModel() ); + $this->addWarning( + [ + 'apierror-parsetree-notwikitext-title', + wfEscapeWikiText( $title->getPrefixedText() ), + $content->getModel() + ], + 'parsetree-notwikitext' + ); } } } @@ -315,9 +321,11 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { ParserOptions::newFromContext( $this->getContext() ) ); } else { - $this->setWarning( "Template expansion is supported for wikitext only, " . - $title->getPrefixedDBkey() . - " uses content model " . $content->getModel() ); + $this->addWarning( [ + 'apierror-templateexpansion-notwikitext', + wfEscapeWikiText( $title->getPrefixedText() ), + $content->getModel() + ] ); $vals['badcontentformat'] = true; $text = false; } @@ -332,13 +340,12 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { } if ( $text === null ) { - $format = $this->contentFormat ? $this->contentFormat : $content->getDefaultFormat(); + $format = $this->contentFormat ?: $content->getDefaultFormat(); $model = $content->getModel(); if ( !$content->isSupportedFormat( $format ) ) { - $name = $title->getPrefixedDBkey(); - $this->setWarning( "The requested format {$this->contentFormat} is not " . - "supported for content model $model used by $name" ); + $name = wfEscapeWikiText( $title->getPrefixedText() ); + $this->addWarning( [ 'apierror-badformat', $this->contentFormat, $model, $name ] ); $vals['badcontentformat'] = true; $text = false; } else { @@ -370,9 +377,8 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { if ( $this->contentFormat && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) { - $name = $title->getPrefixedDBkey(); - $this->setWarning( "The requested format {$this->contentFormat} is not " . - "supported for content model $model used by $name" ); + $name = wfEscapeWikiText( $title->getPrefixedText() ); + $this->addWarning( [ 'apierror-badformat', $this->contentFormat, $model, $name ] ); $vals['diff']['badcontentformat'] = true; $engine = null; } else {