Use english messages for background use of Status::getWikiText
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 10 Apr 2016 12:12:43 +0000 (14:12 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Tue, 12 Apr 2016 18:01:44 +0000 (20:01 +0200)
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

16 files changed:
includes/HttpFunctions.php
includes/api/ApiLogin.php
includes/api/ApiQuerySearch.php
includes/api/ApiUpload.php
includes/filerepo/ForeignAPIRepo.php
includes/filerepo/file/LocalFile.php
includes/jobqueue/jobs/AssembleUploadChunksJob.php
includes/jobqueue/jobs/PublishStashedFileJob.php
includes/session/SessionManager.php
includes/tidy/Html5Depurate.php
maintenance/cleanupCaps.php
maintenance/edit.php
maintenance/importImages.php
maintenance/moveBatch.php
tests/phpunit/maintenance/DumpTestCase.php
thumb.php

index 3f42038..b12f49f 100644 (file)
@@ -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;
                }
index 02aae06..3891415 100644 (file)
@@ -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' )
                                );
                        }
                }
index 2eb5d14..3955cc5 100644 (file)
@@ -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 ) {
index 326f8ba..cdec561 100644 (file)
@@ -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'] );
index cc9099c..b48191f 100644 (file)
@@ -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;
                }
        }
index 9677f5d..7156134 100644 (file)
@@ -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;
index bc2f7c4..16e35f1 100644 (file)
@@ -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;
                        }
index a6d2f70..d2825a8 100644 (file)
@@ -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;
                        }
index fc73335..dd36522 100644 (file)
@@ -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 );
index a34933c..c6acd66 100644 (file)
@@ -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, "<body>" );
index 641250d..6931259 100644 (file)
@@ -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 ) {
index 4ef7379..4219ed0 100644 (file)
@@ -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 );
        }
index 512c38c..c653a5f 100644 (file)
@@ -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;
index 3a1a72c..3c29689 100644 (file)
@@ -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" );
index 7336618..ac83d4e 100644 (file)
@@ -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' ) . ")" );
        }
 
        /**
index 10c2419..fca25c5 100644 (file)
--- 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' ) ] );
                }
        }
 }