chdir( $oldCwd );
# Options processing
- $user = $this->getOption( 'u', 'Move page script' );
+ $user = $this->getOption( 'u', false );
$reason = $this->getOption( 'r', '' );
$interval = $this->getOption( 'i', 0 );
$noredirects = $this->getOption( 'noredirects', false );
if ( !$file ) {
$this->error( "Unable to read file, exiting", true );
}
- $wgUser = User::newFromName( $user );
+ if ( $user === false ) {
+ $wgUser = User::newSystemUser( 'Move page script', array( 'steal' => true ) );
+ } else {
+ $wgUser = User::newFromName( $user );
+ }
if ( !$wgUser ) {
$this->error( "Invalid username", true );
}
$this->output( $source->getPrefixedText() . ' --> ' . $dest->getPrefixedText() );
$dbw->begin( __METHOD__ );
- $err = $source->moveTo( $dest, false, $reason, !$noredirects );
- if ( $err !== true ) {
- $msg = array_shift( $err[0] );
- $this->output( "\nFAILED: " . wfMessage( $msg, $err[0] )->text() );
+ $mp = new MovePage( $source, $dest );
+ $status = $mp->move( $wgUser, $reason, !$noredirects );
+ if ( !$status->isOK() ) {
+ $this->output( "\nFAILED: " . $status->getWikiText() );
}
$dbw->commit( __METHOD__ );
$this->output( "\n" );