2005-08-27 07:47:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
2006-12-26 02:44:03 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script to move a batch of pages
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Maintenance
|
2006-12-26 02:44:03 +00:00
|
|
|
* @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
|
|
|
|
|
* <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
|
|
|
|
|
*/
|
2005-08-27 07:47:27 +00:00
|
|
|
|
|
|
|
|
$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";
|
2005-08-28 00:04:26 +00:00
|
|
|
exit;
|
2005-08-27 07:47:27 +00:00
|
|
|
}
|
|
|
|
|
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2005-08-27 07:47:27 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-12-26 03:08:35 +00:00
|
|
|
print $source->getPrefixedText() . ' --> ' . $dest->getPrefixedText();
|
2005-08-27 07:47:27 +00:00
|
|
|
$dbw->begin();
|
2006-06-28 20:31:04 +00:00
|
|
|
$err = $source->moveTo( $dest, false, $reason );
|
|
|
|
|
if( $err !== true ) {
|
|
|
|
|
print "\nFAILED: $err";
|
|
|
|
|
}
|
2005-08-27 07:47:27 +00:00
|
|
|
$dbw->immediateCommit();
|
2005-08-28 00:04:26 +00:00
|
|
|
print "\n";
|
2005-08-27 07:47:27 +00:00
|
|
|
|
|
|
|
|
if ( $interval ) {
|
|
|
|
|
sleep( $interval );
|
|
|
|
|
}
|
2005-08-28 00:04:26 +00:00
|
|
|
wfWaitForSlaves( 5 );
|
2005-08-27 07:47:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-29 01:19:14 +00:00
|
|
|
|