From ece215199dd3249b87b3ed343c2b8bf06d4e8537 Mon Sep 17 00:00:00 2001 From: Reedy Date: Wed, 24 Nov 2021 19:46:54 +0000 Subject: [PATCH] MoveBatch.php: Minor code cleanup * Swap == for === * Rename a couple of local variables to match common naming patterns * Remove old chdir(); not needed now the code no longer uses commandLine.inc Change-Id: Iabae9b6f4bf57309a7f06cb6740db60e473e1ff2 --- maintenance/moveBatch.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php index bc30a9ed26d..ed67b4e4352 100644 --- a/maintenance/moveBatch.php +++ b/maintenance/moveBatch.php @@ -47,15 +47,11 @@ class MoveBatch extends Maintenance { } public function execute() { - # Change to current working directory - $oldCwd = getcwd(); - chdir( $oldCwd ); - # Options processing $username = $this->getOption( 'u', false ); $reason = $this->getOption( 'r', '' ); $interval = $this->getOption( 'i', 0 ); - $noredirects = $this->hasOption( 'noredirects' ); + $noRedirects = $this->hasOption( 'noredirects' ); if ( $this->hasArg( 0 ) ) { $file = fopen( $this->getArg( 0 ), 'r' ); } else { @@ -78,20 +74,20 @@ class MoveBatch extends Maintenance { # Setup complete, now start $dbw = $this->getDB( DB_PRIMARY ); - for ( $linenum = 1; !feof( $file ); $linenum++ ) { + for ( $lineNum = 1; !feof( $file ); $lineNum++ ) { $line = fgets( $file ); if ( $line === false ) { break; } $parts = array_map( 'trim', explode( '|', $line ) ); - if ( count( $parts ) != 2 ) { - $this->error( "Error on line $linenum, no pipe character" ); + if ( count( $parts ) !== 2 ) { + $this->error( "Error on line $lineNum, no pipe character" ); continue; } $source = Title::newFromText( $parts[0] ); $dest = Title::newFromText( $parts[1] ); if ( $source === null || $dest === null ) { - $this->error( "Invalid title on line $linenum" ); + $this->error( "Invalid title on line $lineNum" ); continue; } @@ -99,7 +95,7 @@ class MoveBatch extends Maintenance { $this->beginTransaction( $dbw, __METHOD__ ); $mp = MediaWikiServices::getInstance()->getMovePageFactory() ->newMovePage( $source, $dest ); - $status = $mp->move( $user, $reason, !$noredirects ); + $status = $mp->move( $user, $reason, !$noRedirects ); if ( !$status->isOK() ) { $this->output( "\nFAILED: " . $status->getMessage( false, false, 'en' )->text() ); }