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
This commit is contained in:
parent
3cec686d81
commit
ece215199d
1 changed files with 6 additions and 10 deletions
|
|
@ -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() );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue