2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-03 20:33:01 +00:00
|
|
|
/**
|
|
|
|
|
* Script for re-attributing edits
|
2009-04-03 22:05:47 +00:00
|
|
|
* Use reassignEdits.php
|
2004-09-03 20:33:01 +00:00
|
|
|
*
|
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
|
2004-09-03 20:33:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** */
|
2004-06-15 15:18:50 +00:00
|
|
|
require_once( "commandLine.inc" );
|
2003-12-22 03:51:30 +00:00
|
|
|
|
|
|
|
|
# Parameters
|
2004-06-15 15:18:50 +00:00
|
|
|
if ( count( $args ) < 2 ) {
|
2003-12-22 03:51:30 +00:00
|
|
|
print "Not enough parameters\n";
|
2004-06-15 15:18:50 +00:00
|
|
|
if ( $wgWikiFarm ) {
|
|
|
|
|
print "Usage: php attribute.php <language> <site> <source> <destination>\n";
|
|
|
|
|
} else {
|
|
|
|
|
print "Usage: php attribute.php <source> <destination>\n";
|
|
|
|
|
}
|
2003-12-22 03:51:30 +00:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-15 15:18:50 +00:00
|
|
|
$source = $args[0];
|
|
|
|
|
$dest = $args[1];
|
2003-12-22 03:51:30 +00:00
|
|
|
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2005-11-01 07:08:37 +00:00
|
|
|
extract( $dbr->tableNames( 'page', 'revision','user' ));
|
2004-07-18 08:48:43 +00:00
|
|
|
$eSource = $dbr->strencode( $source );
|
|
|
|
|
$eDest = $dbr->strencode( $dest );
|
2003-12-22 03:51:30 +00:00
|
|
|
|
|
|
|
|
# Get user id
|
2004-07-18 08:48:43 +00:00
|
|
|
$res = $dbr->query( "SELECT user_id FROM $user WHERE user_name='$eDest'" );
|
|
|
|
|
$row = $dbr->fetchObject( $res );
|
2003-12-22 03:51:30 +00:00
|
|
|
if ( !$row ) {
|
|
|
|
|
print "Warning: the target name \"$dest\" does not exist";
|
|
|
|
|
$uid = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$uid = $row->user_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Initialise files
|
2004-03-14 09:34:28 +00:00
|
|
|
$logfile = fopen( "attribute.log", "a" );
|
|
|
|
|
$sqlfile = fopen( "attribute.sql", "a" );
|
2003-12-22 03:51:30 +00:00
|
|
|
|
|
|
|
|
fwrite( $logfile, "* $source → $dest\n" );
|
|
|
|
|
|
2006-01-07 13:09:30 +00:00
|
|
|
fwrite( $sqlfile,
|
2003-12-22 03:51:30 +00:00
|
|
|
"-- Changing attribution SQL file
|
|
|
|
|
-- Generated with attribute.php
|
|
|
|
|
-- $source -> $dest ($uid)
|
|
|
|
|
");
|
|
|
|
|
|
2004-03-14 09:34:28 +00:00
|
|
|
$omitTitle = "Wikipedia:Changing_attribution_for_an_edit";
|
|
|
|
|
|
2005-11-01 07:08:37 +00:00
|
|
|
# Get revisions
|
|
|
|
|
print "\nPage revisions\n\n";
|
2003-12-22 03:51:30 +00:00
|
|
|
|
2005-11-01 07:08:37 +00:00
|
|
|
$res = $dbr->query( "SELECT page_namespace, page_title, rev_id, rev_timestamp
|
|
|
|
|
FROM $revision,$page
|
|
|
|
|
WHERE rev_user_text='$eSource' and rev_page=page_id" );
|
2004-07-18 08:48:43 +00:00
|
|
|
$row = $dbr->fetchObject( $res );
|
2003-12-22 03:51:30 +00:00
|
|
|
|
|
|
|
|
if ( $row ) {
|
|
|
|
|
/*
|
|
|
|
|
if ( $row->old_title=='Votes_for_deletion' && $row->old_namespace == 4 ) {
|
|
|
|
|
# We don't have that long
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
*/
|
2005-11-01 07:08:37 +00:00
|
|
|
fwrite( $logfile, "**Revision IDs: " );
|
|
|
|
|
fwrite( $sqlfile, "UPDATE $revision SET rev_user=$uid, rev_user_text='$eDest' WHERE rev_id IN (\n" );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2004-07-18 08:48:43 +00:00
|
|
|
for ( $first=true; $row; $row = $dbr->fetchObject( $res ) ) {
|
2005-11-01 07:08:37 +00:00
|
|
|
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
|
|
|
|
|
$fullTitle = $title->getPrefixedDbKey();
|
2004-03-14 09:34:28 +00:00
|
|
|
if ( $fullTitle == $omitTitle ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print "$fullTitle\n";
|
2005-11-01 07:08:37 +00:00
|
|
|
$url = $title->getFullUrl( "oldid={$row->rev_id}" );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2003-12-22 03:51:30 +00:00
|
|
|
# Output
|
|
|
|
|
fwrite( $sqlfile, " " );
|
|
|
|
|
if ( $first ) {
|
|
|
|
|
$first = false;
|
|
|
|
|
} else {
|
|
|
|
|
fwrite( $sqlfile, ", " );
|
|
|
|
|
fwrite( $logfile, ", " );
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-01 07:08:37 +00:00
|
|
|
fwrite( $sqlfile, "{$row->rev_id} -- $url\n" );
|
|
|
|
|
fwrite( $logfile, "[$url {$row->rev_id}]" );
|
2003-12-22 03:51:30 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
fwrite( $sqlfile, ");\n" );
|
|
|
|
|
fwrite( $logfile, "\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
|
|
fclose( $sqlfile );
|
|
|
|
|
fclose( $logfile );
|
|
|
|
|
|
2007-06-29 01:19:14 +00:00
|
|
|
|