From: umherirrender Date: Sun, 10 Apr 2016 12:12:43 +0000 (+0200) Subject: Use english messages for background use of Status::getWikiText X-Git-Tag: 1.31.0-rc.0~7302^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22statistiques_visites%22%2C%22%22%29%20.%20%22?a=commitdiff_plain;h=932c37e3cb1708965ca52622dc23b9c4a635f304;p=lhc%2Fweb%2Fwiklou.git Use english messages for background use of Status::getWikiText Status::getWikiText is used for internal logging, api error messages and maintenance scripts. All this places are usually in english, so pass an english language to getWikiText. Change-Id: I3010fca8eb5740a3a851c55a8b12e171714c78f7 --- diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 3f42038242..b12f49f0b0 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -80,7 +80,7 @@ class Http { } else { $errors = $status->getErrorsByType( 'error' ); $logger = LoggerFactory::getInstance( 'http' ); - $logger->warning( $status->getWikiText( null, null, 'en' ), + $logger->warning( $status->getWikiText( false, false, 'en' ), [ 'error' => $errors, 'caller' => $caller, 'content' => $req->getContent() ] ); return false; } diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php index 02aae06e80..3891415f5e 100644 --- a/includes/api/ApiLogin.php +++ b/includes/api/ApiLogin.php @@ -103,7 +103,7 @@ class ApiLogin extends ApiBase { $loginType = 'BotPassword'; } else { LoggerFactory::getInstance( 'authmanager' )->info( - 'BotPassword login failed: ' . $status->getWikiText() + 'BotPassword login failed: ' . $status->getWikiText( false, false, 'en' ) ); } } diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 2eb5d14ea3..3955cc5f67 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -116,7 +116,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { if ( is_null( $matches ) ) { $this->dieUsage( "{$what} search is disabled", "search-{$what}-disabled" ); } elseif ( $matches instanceof Status && !$matches->isGood() ) { - $this->dieUsage( $matches->getWikiText(), 'search-error' ); + $this->dieUsage( $matches->getWikiText( false, false, 'en' ), 'search-error' ); } if ( $resultPageSet === null ) { diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 326f8ba112..cdec561af8 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -257,7 +257,7 @@ class ApiUpload extends ApiBase { 'offset' => $this->mUpload->getOffset(), ]; - $this->dieUsage( $status->getWikiText(), 'stashfailed', 0, $extradata ); + $this->dieUsage( $status->getWikiText( false, false, 'en' ), 'stashfailed', 0, $extradata ); } } @@ -288,7 +288,7 @@ class ApiUpload extends ApiBase { $filekey, [ 'result' => 'Failure', 'stage' => 'assembling', 'status' => $status ] ); - $this->dieUsage( $status->getWikiText(), 'stashfailed' ); + $this->dieUsage( $status->getWikiText( false, false, 'en' ), 'stashfailed' ); } // The fully concatenated file has a new filekey. So remove @@ -391,7 +391,7 @@ class ApiUpload extends ApiBase { if ( !$progress ) { $this->dieUsage( 'No result in status data', 'missingresult' ); } elseif ( !$progress['status']->isGood() ) { - $this->dieUsage( $progress['status']->getWikiText(), 'stashfailed' ); + $this->dieUsage( $progress['status']->getWikiText( false, false, 'en' ), 'stashfailed' ); } if ( isset( $progress['status']->value['verification'] ) ) { $this->checkVerification( $progress['status']->value['verification'] ); diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index cc9099c6c0..b48191fd1c 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -527,7 +527,10 @@ class ForeignAPIRepo extends FileRepo { return $req->getContent(); } else { $logger = LoggerFactory::getInstance( 'http' ); - $logger->warning( $status->getWikiText(), [ 'caller' => 'ForeignAPIRepo::httpGet' ] ); + $logger->warning( + $status->getWikiText( false, false, 'en' ), + [ 'caller' => 'ForeignAPIRepo::httpGet' ] + ); return false; } } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 9677f5d4fa..7156134017 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -2881,7 +2881,8 @@ class LocalFileMoveBatch { $this->cleanupTarget( $triplets ); $destFile->unlock(); $this->file->unlockAndRollback(); // unlocks the destination - wfDebugLog( 'imagemove', "Error in moving files: " . $statusMove->getWikiText() ); + wfDebugLog( 'imagemove', "Error in moving files: " + . $statusMove->getWikiText( false, false, 'en' ) ); $statusMove->ok = false; return $statusMove; diff --git a/includes/jobqueue/jobs/AssembleUploadChunksJob.php b/includes/jobqueue/jobs/AssembleUploadChunksJob.php index bc2f7c458a..16e35f1eab 100644 --- a/includes/jobqueue/jobs/AssembleUploadChunksJob.php +++ b/includes/jobqueue/jobs/AssembleUploadChunksJob.php @@ -69,7 +69,7 @@ class AssembleUploadChunksJob extends Job { $this->params['filekey'], [ 'result' => 'Failure', 'stage' => 'assembling', 'status' => $status ] ); - $this->setLastError( $status->getWikiText() ); + $this->setLastError( $status->getWikiText( false, false, 'en' ) ); return false; } diff --git a/includes/jobqueue/jobs/PublishStashedFileJob.php b/includes/jobqueue/jobs/PublishStashedFileJob.php index a6d2f70f4d..d2825a8b91 100644 --- a/includes/jobqueue/jobs/PublishStashedFileJob.php +++ b/includes/jobqueue/jobs/PublishStashedFileJob.php @@ -92,7 +92,7 @@ class PublishStashedFileJob extends Job { $this->params['filekey'], [ 'result' => 'Failure', 'stage' => 'publish', 'status' => $status ] ); - $this->setLastError( $status->getWikiText() ); + $this->setLastError( $status->getWikiText( false, false, 'en' ) ); return false; } diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index fc73335244..dd365227a8 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -498,10 +498,12 @@ final class SessionManager implements SessionManagerInterface { 'username' => $userName, ] ); } else { - $logger->error( __METHOD__ . ': failed with message ' . $status->getWikiText(), + $logger->error( + __METHOD__ . ': failed with message ' . $status->getWikiText( false, false, 'en' ), [ 'username' => $userName, - ] ); + ] + ); } $user->setId( $id ); $user->loadFromId( User::READ_LATEST ); diff --git a/includes/tidy/Html5Depurate.php b/includes/tidy/Html5Depurate.php index a34933ca1d..c6acd661f2 100644 --- a/includes/tidy/Html5Depurate.php +++ b/includes/tidy/Html5Depurate.php @@ -29,9 +29,10 @@ class Html5Depurate extends TidyDriverBase { ] ); $status = $req->execute(); if ( !$status->isOK() ) { - throw new Exception( "Error contacting depurate service: " . $status->getWikiText() ); + throw new Exception( "Error contacting depurate service: " + . $status->getWikiText( false, false, 'en' ) ); } elseif ( $req->getStatus() !== 200 ) { - throw new Exception( "Depurate returned error: " . $status->getWikiText() ); + throw new Exception( "Depurate returned error: " . $status->getWikiText( false, false, 'en' ) ); } $result = $req->getContent(); $startBody = strpos( $result, "" ); diff --git a/maintenance/cleanupCaps.php b/maintenance/cleanupCaps.php index 641250d102..693125994c 100644 --- a/maintenance/cleanupCaps.php +++ b/maintenance/cleanupCaps.php @@ -92,7 +92,7 @@ class CapsCleanup extends TableCleanup { } else { $mp = new MovePage( $current, $target ); $status = $mp->move( $this->user, 'Converting page titles to lowercase', true ); - $ok = $status->isOK() ? 'OK' : $status->getWikiText(); + $ok = $status->isOK() ? 'OK' : $status->getWikiText( false, false, 'en' ); $this->output( "\"$display\" -> \"$targetDisplay\": $ok\n" ); } if ( $ok === true ) { diff --git a/maintenance/edit.php b/maintenance/edit.php index 4ef73799d4..4219ed0517 100644 --- a/maintenance/edit.php +++ b/maintenance/edit.php @@ -97,7 +97,7 @@ class EditCLI extends Maintenance { $exit = 1; } if ( !$status->isGood() ) { - $this->output( $status->getWikiText() . "\n" ); + $this->output( $status->getWikiText( false, false, 'en' ) . "\n" ); } exit( $exit ); } diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 512c38cb32..c653a5f06d 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -257,7 +257,7 @@ if ( $count > 0 ) { $archive = $image->publish( $file, $flags, $publishOptions ); if ( !$archive->isGood() ) { echo "failed. (" . - $archive->getWikiText() . + $archive->getWikiText( false, false, 'en' ) . ")\n"; $failed++; continue; diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php index 3a1a72c81d..3c2968988a 100644 --- a/maintenance/moveBatch.php +++ b/maintenance/moveBatch.php @@ -110,7 +110,7 @@ class MoveBatch extends Maintenance { $mp = new MovePage( $source, $dest ); $status = $mp->move( $wgUser, $reason, !$noredirects ); if ( !$status->isOK() ) { - $this->output( "\nFAILED: " . $status->getWikiText() ); + $this->output( "\nFAILED: " . $status->getWikiText( false, false, 'en' ) ); } $this->commitTransaction( $dbw, __METHOD__ ); $this->output( "\n" ); diff --git a/tests/phpunit/maintenance/DumpTestCase.php b/tests/phpunit/maintenance/DumpTestCase.php index 7336618ebf..ac83d4e70a 100644 --- a/tests/phpunit/maintenance/DumpTestCase.php +++ b/tests/phpunit/maintenance/DumpTestCase.php @@ -53,7 +53,8 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { } } - throw new MWException( "Could not determine revision id (" . $status->getWikiText() . ")" ); + throw new MWException( "Could not determine revision id (" + . $status->getWikiText( false, false, 'en' ) . ")" ); } /** diff --git a/thumb.php b/thumb.php index 10c2419db1..fca25c55d2 100644 --- a/thumb.php +++ b/thumb.php @@ -320,7 +320,7 @@ function wfStreamThumb( array $params ) { RequestContext::getMain()->getStats()->timing( 'media.thumbnail.stream', $streamtime ); } else { wfThumbError( 500, 'Could not stream the file', null, [ 'file' => $thumbName, - 'path' => $thumbPath, 'error' => $status->getWikiText() ] ); + 'path' => $thumbPath, 'error' => $status->getWikiText( false, false, 'en' ) ] ); } return; } @@ -366,7 +366,8 @@ function wfStreamThumb( array $params ) { $status = $thumb->streamFileWithStatus( $headers ); if ( !$status->isOK() ) { wfThumbError( 500, 'Could not stream the file', null, [ - 'file' => $thumbName, 'path' => $thumbPath, 'error' => $status->getWikiText() ] ); + 'file' => $thumbName, 'path' => $thumbPath, + 'error' => $status->getWikiText( false, false, 'en' ) ] ); } } }