From db3a8beb778ba841cf6bf795312bdba796c58ee5 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Tue, 18 Sep 2018 22:01:56 +0200 Subject: [PATCH] Pass language to Status::getWikiText Avoid use of $wgLang Change-Id: I9cd633a20c5c60e56a101a9a699eea6db8b8eef0 --- includes/EditPage.php | 7 +++++-- includes/ProtectionForm.php | 4 +++- includes/page/Article.php | 6 ++++-- includes/specialpage/LoginSignupSpecialPage.php | 4 +++- includes/specials/SpecialConfirmEmail.php | 2 +- includes/specials/SpecialEditTags.php | 2 +- includes/specials/SpecialImport.php | 7 ++++--- includes/specials/SpecialRevisionDelete.php | 2 +- includes/specials/SpecialUndelete.php | 6 ++++-- includes/specials/SpecialUpload.php | 10 +++++++--- includes/specials/SpecialUserrights.php | 12 +++++++++--- 11 files changed, 42 insertions(+), 20 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 9182300fcf..fe00149920 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1683,7 +1683,9 @@ class EditPage { case self::AS_CANNOT_USE_CUSTOM_MODEL: case self::AS_PARSE_ERROR: case self::AS_UNICODE_NOT_SUPPORTED: - $out->wrapWikiTextAsInterface( 'error', $status->getWikiText() ); + $out->wrapWikiTextAsInterface( 'error', + $status->getWikiText( false, false, $this->context->getLanguage() ) + ); return true; case self::AS_SUCCESS_NEW_ARTICLE: @@ -1757,7 +1759,8 @@ class EditPage { // is if an extension hook aborted from inside ArticleSave. // Render the status object into $this->hookError // FIXME this sucks, we should just use the Status object throughout - $this->hookError = '
' . "\n" . $status->getWikiText() . + $this->hookError = '
' . "\n" . + $status->getWikiText( false, false, $this->context->getLanguage() ) . '
'; return true; } diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index a1be271848..3e639b92a2 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -333,7 +333,9 @@ class ProtectionForm { ); if ( !$status->isOK() ) { - $this->show( $out->parseInlineAsInterface( $status->getWikiText() ) ); + $this->show( $out->parseInlineAsInterface( + $status->getWikiText( false, false, $this->mContext->getLanguage() ) + ) ); return false; } diff --git a/includes/page/Article.php b/includes/page/Article.php index 6aeb038251..4b37181c24 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -808,7 +808,9 @@ class Article implements Page { $outputPage->enableClientCache( false ); $outputPage->setRobotPolicy( 'noindex,nofollow' ); - $errortext = $error->getWikiText( false, 'view-pool-error' ); + $errortext = $error->getWikiText( + false, 'view-pool-error', $this->getContext()->getLanguage() + ); $outputPage->wrapWikiTextAsInterface( 'errorbox', $errortext ); } # Connection or timeout error @@ -2121,7 +2123,7 @@ class Article implements Page { if ( $error == '' ) { $outputPage->wrapWikiTextAsInterface( 'error mw-error-cannotdelete', - $status->getWikiText() + $status->getWikiText( false, false, $context->getLanguage() ) ); $deleteLogPage = new LogPage( 'delete' ); $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) ); diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php index 94be8521a3..8be029aac8 100644 --- a/includes/specialpage/LoginSignupSpecialPage.php +++ b/includes/specialpage/LoginSignupSpecialPage.php @@ -441,7 +441,9 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { } if ( $extraMessages ) { $extraMessages = Status::wrap( $extraMessages ); - $out->addWikiTextAsInterface( $extraMessages->getWikiText() ); + $out->addWikiTextAsInterface( + $extraMessages->getWikiText( false, false, $this->getLanguage() ) + ); } $out->addHTML( $injected_html ); diff --git a/includes/specials/SpecialConfirmEmail.php b/includes/specials/SpecialConfirmEmail.php index 2c42cd386a..dc31eba61a 100644 --- a/includes/specials/SpecialConfirmEmail.php +++ b/includes/specials/SpecialConfirmEmail.php @@ -141,7 +141,7 @@ class SpecialConfirmEmail extends UnlistedSpecialPage { return Status::newGood( $this->msg( 'confirmemail_sent' )->text() ); } else { return Status::newFatal( new RawMessage( - $status->getWikiText( 'confirmemail_sendfailed' ) + $status->getWikiText( 'confirmemail_sendfailed', false, $this->getLanguage() ) ) ); } } diff --git a/includes/specials/SpecialEditTags.php b/includes/specials/SpecialEditTags.php index 48357aa7ad..0b4577eb98 100644 --- a/includes/specials/SpecialEditTags.php +++ b/includes/specials/SpecialEditTags.php @@ -465,7 +465,7 @@ class SpecialEditTags extends UnlistedSpecialPage { protected function failure( $status ) { $this->getOutput()->setPageTitle( $this->msg( 'actionfailed' ) ); $this->getOutput()->wrapWikiTextAsInterface( - 'errorbox', $status->getWikiText( 'tags-edit-failure' ) + 'errorbox', $status->getWikiText( 'tags-edit-failure', false, $this->getLanguage() ) ); $this->showForm(); } diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index cfefa47642..428556f33d 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -187,7 +187,8 @@ class SpecialImport extends SpecialPage { $out = $this->getOutput(); if ( !$source->isGood() ) { $out->wrapWikiTextAsInterface( 'error', - $this->msg( 'importfailed', $source->getWikiText() )->plain() + $this->msg( 'importfailed', $source->getWikiText( false, false, $this->getLanguage() ) ) + ->plain() ); } else { $importer = new WikiImporter( $source->value, $this->getConfig() ); @@ -200,7 +201,7 @@ class SpecialImport extends SpecialPage { "
\n$1\n
", [ 'import-options-wrong', - $statusRootPage->getWikiText(), + $statusRootPage->getWikiText( false, false, $this->getLanguage() ), count( $statusRootPage->getErrorsArray() ) ] ); @@ -239,7 +240,7 @@ class SpecialImport extends SpecialPage { # Zero revisions $out->wrapWikiMsg( "
\n$1\n
", - [ 'importfailed', $result->getWikiText() ] + [ 'importfailed', $result->getWikiText( false, false, $this->getLanguage() ) ] ); } else { # Success! diff --git a/includes/specials/SpecialRevisionDelete.php b/includes/specials/SpecialRevisionDelete.php index 67177b7c6c..750e2c3dc3 100644 --- a/includes/specials/SpecialRevisionDelete.php +++ b/includes/specials/SpecialRevisionDelete.php @@ -667,7 +667,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->getOutput()->setPageTitle( $this->msg( 'actionfailed' ) ); $this->getOutput()->wrapWikiTextAsInterface( 'errorbox', - $status->getWikiText( $this->typeLabels['failure'] ) + $status->getWikiText( $this->typeLabels['failure'], false, $this->getLanguage() ) ); $this->showForm(); } diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index d3d3bd7b06..c6f07217f1 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -1216,7 +1216,8 @@ class SpecialUndelete extends SpecialPage { '
' . $status->getWikiText( 'cannotundelete', - 'cannotundelete' + 'cannotundelete', + $this->getLanguage() ) . '
' ); } @@ -1228,7 +1229,8 @@ class SpecialUndelete extends SpecialPage { 'error', $status->getWikiText( 'undelete-error-short', - 'undelete-error-long' + 'undelete-error-long', + $this->getLanguage() ) ); } diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index e7c2e42a77..a2edca0850 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -488,7 +488,9 @@ class SpecialUpload extends SpecialPage { // Fetch the file if required $status = $this->mUpload->fetchFile(); if ( !$status->isOK() ) { - $this->showUploadError( $this->getOutput()->parseAsInterface( $status->getWikiText() ) ); + $this->showUploadError( $this->getOutput()->parseAsInterface( + $status->getWikiText( false, false, $this->getLanguage() ) + ) ); return; } @@ -559,7 +561,7 @@ class SpecialUpload extends SpecialPage { $changeTags, $this->getUser() ); if ( !$changeTagsStatus->isOK() ) { $this->showUploadError( $this->getOutput()->parseAsInterface( - $changeTagsStatus->getWikiText() + $changeTagsStatus->getWikiText( false, false, $this->getLanguage() ) ) ); return; @@ -576,7 +578,9 @@ class SpecialUpload extends SpecialPage { if ( !$status->isGood() ) { $this->showRecoverableUploadError( - $this->getOutput()->parseAsInterface( $status->getWikiText() ) + $this->getOutput()->parseAsInterface( + $status->getWikiText( false, false, $this->getLanguage() ) + ) ); return; diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 585699ddd0..28626ea58e 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -177,7 +177,9 @@ class UserrightsPage extends SpecialPage { // save settings if ( !$fetchedStatus->isOK() ) { - $this->getOutput()->addWikiTextAsInterface( $fetchedStatus->getWikiText() ); + $this->getOutput()->addWikiTextAsInterface( + $fetchedStatus->getWikiText( false, false, $this->getLanguage() ) + ); return; } @@ -208,7 +210,9 @@ class UserrightsPage extends SpecialPage { return; } else { // Print an error message and redisplay the form - $out->wrapWikiTextAsInterface( 'error', $status->getWikiText() ); + $out->wrapWikiTextAsInterface( + 'error', $status->getWikiText( false, false, $this->getLanguage() ) + ); } } } @@ -482,7 +486,9 @@ class UserrightsPage extends SpecialPage { function editUserGroupsForm( $username ) { $status = $this->fetchUser( $username, true ); if ( !$status->isOK() ) { - $this->getOutput()->addWikiTextAsInterface( $status->getWikiText() ); + $this->getOutput()->addWikiTextAsInterface( + $status->getWikiText( false, false, $this->getLanguage() ) + ); return; } -- 2.20.1