From 1eb5d8e44d7f0476a3f85b3f7e15d7f2cbc51f9e Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Mon, 19 Aug 2019 18:12:32 +0200 Subject: [PATCH] Do not output wikitext in maintenance script Also remove print_r with a string Always use english for maintenance scripts Bug: T229843 Change-Id: I539a1ac1f6a201dd8ee9ce89599cc34bebfba79f --- maintenance/addChangeTag.php | 2 +- maintenance/changePassword.php | 2 +- maintenance/cleanupCaps.php | 2 +- maintenance/copyFileBackend.php | 6 +++--- maintenance/createAndPromote.php | 4 ++-- maintenance/edit.php | 2 +- maintenance/importDump.php | 2 +- maintenance/importImages.php | 2 +- maintenance/install.php | 2 +- maintenance/moveBatch.php | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/maintenance/addChangeTag.php b/maintenance/addChangeTag.php index b63a2e2b82..c1a1b079f3 100644 --- a/maintenance/addChangeTag.php +++ b/maintenance/addChangeTag.php @@ -52,7 +52,7 @@ class AddChangeTag extends Maintenance { ); if ( !$status->isGood() ) { - $this->fatalError( $status->getWikiText( null, null, 'en' ) ); + $this->fatalError( $status->getMessage( false, false, 'en' )->text() ); } $this->output( "$tag was created.\n" ); diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php index e7df448f7a..aa45154ddd 100644 --- a/maintenance/changePassword.php +++ b/maintenance/changePassword.php @@ -60,7 +60,7 @@ class ChangePassword extends Maintenance { if ( $status->isGood() ) { $this->output( "Password set for " . $user->getName() . "\n" ); } else { - $this->fatalError( $status->getWikiText( null, null, 'en' ) ); + $this->fatalError( $status->getMessage( false, false, 'en' )->text() ); } } } diff --git a/maintenance/cleanupCaps.php b/maintenance/cleanupCaps.php index da241e5337..2c81adf070 100644 --- a/maintenance/cleanupCaps.php +++ b/maintenance/cleanupCaps.php @@ -163,7 +163,7 @@ class CleanupCaps extends TableCleanup { $mp = MediaWikiServices::getInstance()->getMovePageFactory() ->newMovePage( $current, $target ); $status = $mp->move( $this->user, $reason, $createRedirect ); - $ok = $status->isOK() ? 'OK' : $status->getWikiText( false, false, 'en' ); + $ok = $status->isOK() ? 'OK' : $status->getMessage( false, false, 'en' )->text(); $this->output( "\"$display\" -> \"$targetDisplay\": $ok\n" ); } diff --git a/maintenance/copyFileBackend.php b/maintenance/copyFileBackend.php index ce4063842c..9e36742726 100644 --- a/maintenance/copyFileBackend.php +++ b/maintenance/copyFileBackend.php @@ -260,7 +260,7 @@ class CopyFileBackend extends Maintenance { // Note: prepare() is usually fast for key/value backends $status = $dst->prepare( [ 'dir' => dirname( $dstPath ), 'bypassReadOnly' => 1 ] ); if ( !$status->isOK() ) { - $this->error( print_r( Status::wrap( $status )->getWikiText(), true ) ); + $this->error( Status::wrap( $status )->getMessage( false, false, 'en' )->text() ); $this->fatalError( "$domainId: Could not copy $srcPath to $dstPath." ); } $ops[] = [ 'op' => 'store', @@ -277,7 +277,7 @@ class CopyFileBackend extends Maintenance { } $elapsed_ms = floor( ( microtime( true ) - $t_start ) * 1000 ); if ( !$status->isOK() ) { - $this->error( print_r( Status::wrap( $status )->getWikiText(), true ) ); + $this->error( Status::wrap( $status )->getMessage( false, false, 'en' )->text() ); $this->fatalError( "$domainId: Could not copy file batch." ); } elseif ( count( $copiedRel ) ) { $this->output( "\n\tCopied these file(s) [{$elapsed_ms}ms]:\n\t" . @@ -314,7 +314,7 @@ class CopyFileBackend extends Maintenance { } $elapsed_ms = floor( ( microtime( true ) - $t_start ) * 1000 ); if ( !$status->isOK() ) { - $this->error( print_r( Status::wrap( $status )->getWikiText(), true ) ); + $this->error( Status::wrap( $status )->getMessage( false, false, 'en' )->text() ); $this->fatalError( "$domainId: Could not delete file batch." ); } elseif ( count( $deletedRel ) ) { $this->output( "\n\tDeleted these file(s) [{$elapsed_ms}ms]:\n\t" . diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 505168e84b..b92735b1a5 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -121,7 +121,7 @@ class CreateAndPromote extends Maintenance { false ); if ( !$status->isGood() ) { - $this->fatalError( $status->getWikiText( null, null, 'en' ) ); + $this->fatalError( $status->getMessage( false, false, 'en' )->text() ); } } @@ -134,7 +134,7 @@ class CreateAndPromote extends Maintenance { 'retype' => $password, ] ); if ( !$status->isGood() ) { - throw new PasswordError( $status->getWikiText( null, null, 'en' ) ); + throw new PasswordError( $status->getMessage( false, false, 'en' )->text() ); } if ( $exists ) { $this->output( "Password set.\n" ); diff --git a/maintenance/edit.php b/maintenance/edit.php index 3609cf2249..825e9caf21 100644 --- a/maintenance/edit.php +++ b/maintenance/edit.php @@ -122,7 +122,7 @@ class EditCLI extends Maintenance { $exit = 1; } if ( !$status->isGood() ) { - $this->output( $status->getWikiText( false, false, 'en' ) . "\n" ); + $this->output( $status->getMessage( false, false, 'en' )->text() . "\n" ); } exit( $exit ); } diff --git a/maintenance/importDump.php b/maintenance/importDump.php index d5f94ad8ab..6640148a28 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -326,7 +326,7 @@ TEXT $statusRootPage = $importer->setTargetRootPage( $this->getOption( 'rootpage' ) ); if ( !$statusRootPage->isGood() ) { // Die here so that it doesn't print "Done!" - $this->fatalError( $statusRootPage->getMessage()->text() ); + $this->fatalError( $statusRootPage->getMessage( false, false, 'en' )->text() ); return false; } } diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 954f36d3a2..0c4ff0af50 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -326,7 +326,7 @@ class ImportImages extends Maintenance { $archive = $image->publish( $file, $flags, $publishOptions ); if ( !$archive->isGood() ) { $this->output( "failed. (" . - $archive->getWikiText( false, false, 'en' ) . + $archive->getMessage( false, false, 'en' )->text() . ")\n" ); $failed++; continue; diff --git a/maintenance/install.php b/maintenance/install.php index 16b8ccf837..20254b0c05 100644 --- a/maintenance/install.php +++ b/maintenance/install.php @@ -118,7 +118,7 @@ class CommandLineInstaller extends Maintenance { try { $installer = InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions ); } catch ( \MediaWiki\Installer\InstallException $e ) { - $this->output( $e->getStatus()->getMessage()->text() . "\n" ); + $this->output( $e->getStatus()->getMessage( false, false, 'en' )->text() . "\n" ); return false; } diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php index 09f3120a97..b54ed4566b 100644 --- a/maintenance/moveBatch.php +++ b/maintenance/moveBatch.php @@ -111,7 +111,7 @@ class MoveBatch extends Maintenance { ->newMovePage( $source, $dest ); $status = $mp->move( $wgUser, $reason, !$noredirects ); if ( !$status->isOK() ) { - $this->output( "\nFAILED: " . $status->getWikiText( false, false, 'en' ) ); + $this->output( "\nFAILED: " . $status->getMessage( false, false, 'en' )->text() ); } $this->commitTransaction( $dbw, __METHOD__ ); $this->output( "\n" ); -- 2.20.1