From 183851b06bd6c52f3cae5375f433da720d410447 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 18:12:39 +0000 Subject: MediaWiki 1.7.1 wiederhergestellt --- maintenance/moveBatch.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 maintenance/moveBatch.php (limited to 'maintenance/moveBatch.php') diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php new file mode 100644 index 00000000..8d7141cd --- /dev/null +++ b/maintenance/moveBatch.php @@ -0,0 +1,85 @@ +] [-r ] [-i ] +# where +# is a file where each line has two titles separated by a pipe +# character. The first title is the source, the second is the destination. +# is the username +# is the move reason +# is the number of seconds to sleep for after each move + +$oldCwd = getcwd(); +$optionsWithArgs = array( 'u', 'r', 'i' ); +require_once( 'commandLine.inc' ); + +chdir( $oldCwd ); + +# Options processing + +$filename = 'php://stdin'; +$user = 'Move page script'; +$reason = ''; +$interval = 0; + +if ( isset( $args[0] ) ) { + $filename = $args[0]; +} +if ( isset( $options['u'] ) ) { + $user = $options['u']; +} +if ( isset( $options['r'] ) ) { + $reason = $options['r']; +} +if ( isset( $options['i'] ) ) { + $interval = $options['i']; +} + +$wgUser = User::newFromName( $user ); + + +# Setup complete, now start + +$file = fopen( $filename, 'r' ); +if ( !$file ) { + print "Unable to read file, exiting\n"; + exit; +} + +$dbw =& wfGetDB( DB_MASTER ); + +for ( $linenum = 1; !feof( $file ); $linenum++ ) { + $line = fgets( $file ); + if ( $line === false ) { + break; + } + $parts = array_map( 'trim', explode( '|', $line ) ); + if ( count( $parts ) != 2 ) { + print "Error on line $linenum, no pipe character\n"; + continue; + } + $source = Title::newFromText( $parts[0] ); + $dest = Title::newFromText( $parts[1] ); + if ( is_null( $source ) || is_null( $dest ) ) { + print "Invalid title on line $linenum\n"; + continue; + } + + + print $source->getPrefixedText(); + $dbw->begin(); + $err = $source->moveTo( $dest, false, $reason ); + if( $err !== true ) { + print "\nFAILED: $err"; + } + $dbw->immediateCommit(); + print "\n"; + + if ( $interval ) { + sleep( $interval ); + } + wfWaitForSlaves( 5 ); +} + + +?> -- cgit v1.2.2