Localisation updates for core messages from translatewiki.net (2009-07-22 23:12 UTC)
[lhc/web/wiklou.git] / maintenance / moveBatch.php
index 6355bc4..427e5d0 100644 (file)
@@ -1,13 +1,24 @@
 <?php
 
-# Move a batch of pages
-# Usage: php moveBatch.php [-u <user>] [-r <reason>] [-i <interval>] <listfile>
-# where 
-#      <listfile> 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.
-#      <user> is the username
-#      <reason> is the move reason
-#      <interval> is the number of seconds to sleep for after each move
+/**
+ * Maintenance script to move a batch of pages
+ *
+ * @file
+ * @ingroup Maintenance
+ * @author Tim Starling
+ *
+ * USAGE: php moveBatch.php [-u <user>] [-r <reason>] [-i <interval>] [listfile]
+ *
+ * [listfile] - file with two titles per line, separated with pipe characters;
+ * the first title is the source, the second is the destination.
+ * Standard input is used if listfile is not given.
+ * <user> - username to perform moves as
+ * <reason> - reason to be given for moves
+ * <interval> - number of seconds to sleep after each move
+ *
+ * This will print out error codes from Title::moveTo() if something goes wrong,
+ * e.g. immobile_namespace for namespaces which can't be moved
+ */
 
 $oldCwd = getcwd();
 $optionsWithArgs = array( 'u', 'r', 'i' );
@@ -43,9 +54,10 @@ $wgUser = User::newFromName( $user );
 $file = fopen( $filename, 'r' );
 if ( !$file ) {
        print "Unable to read file, exiting\n";
+       exit;
 }
 
-$dbw =& wfGetDB( DB_MASTER );
+$dbw = wfGetDB( DB_MASTER );
 
 for ( $linenum = 1; !feof( $file ); $linenum++ ) {
        $line = fgets( $file );
@@ -65,15 +77,20 @@ for ( $linenum = 1; !feof( $file ); $linenum++ ) {
        }
 
 
+       print $source->getPrefixedText() . ' --> ' . $dest->getPrefixedText();
        $dbw->begin();
-       $source->moveTo( $dest, false, $reason );
+       $err = $source->moveTo( $dest, false, $reason );
+       if( $err !== true ) {
+               print "\nFAILED: $err";
+       }
        $dbw->immediateCommit();
+       print "\n";
 
-       wfWaitForSlaves( 5 );
        if ( $interval ) {
                sleep( $interval );
        }
+       wfWaitForSlaves( 5 );
 }
 
 
-?>
+