Do not output wikitext in maintenance script
authorUmherirrender <umherirrender_de.wp@web.de>
Mon, 19 Aug 2019 16:12:32 +0000 (18:12 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Fri, 20 Sep 2019 16:28:34 +0000 (18:28 +0200)
Also remove print_r with a string
Always use english for maintenance scripts

Bug: T229843
Change-Id: I539a1ac1f6a201dd8ee9ce89599cc34bebfba79f

maintenance/addChangeTag.php
maintenance/changePassword.php
maintenance/cleanupCaps.php
maintenance/copyFileBackend.php
maintenance/createAndPromote.php
maintenance/edit.php
maintenance/importDump.php
maintenance/importImages.php
maintenance/install.php
maintenance/moveBatch.php

index b63a2e2..c1a1b07 100644 (file)
@@ -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" );
index e7df448..aa45154 100644 (file)
@@ -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() );
                }
        }
 }
index da241e5..2c81adf 100644 (file)
@@ -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" );
                }
 
index ce40638..9e36742 100644 (file)
@@ -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" .
index 505168e..b92735b 100644 (file)
@@ -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" );
index 3609cf2..825e9ca 100644 (file)
@@ -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 );
        }
index d5f94ad..6640148 100644 (file)
@@ -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;
                        }
                }
index 954f36d..0c4ff0a 100644 (file)
@@ -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;
index 16b8ccf..20254b0 100644 (file)
@@ -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;
                }
 
index 09f3120..b54ed45 100644 (file)
@@ -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" );