Go to the documentation of this file.
26 require_once __DIR__ .
'/Maintenance.php';
36 parent::__construct();
37 $this->mDescription =
"Reassign edits from one user to another";
38 $this->
addOption(
"force",
"Reassign even if the target user doesn't exist" );
39 $this->
addOption(
"norc",
"Don't update the recent changes table" );
40 $this->
addOption(
"report",
"Print out details of what would be changed, but don't update it" );
41 $this->
addArg(
'from',
'Old user to take edits from' );
42 $this->
addArg(
'to',
'New user to give edits to' );
47 # Set up the users involved
51 # If the target doesn't exist, and --force is not set, stop here
52 if ( $to->getId() || $this->
hasOption(
'force' ) ) {
56 # If reporting, and there were items, advise the user to run without --report
58 $this->
output(
"Run the script again without --report to update.\n" );
61 $ton = $to->getName();
62 $this->
error(
"User '{$ton}' not found." );
78 $dbw->begin( __METHOD__ );
81 $this->
output(
"Checking current edits..." );
82 $res = $dbw->select(
'revision',
'COUNT(*) AS count', $this->
userConditions(
$from,
'rev_user',
'rev_user_text' ), __METHOD__ );
83 $row = $dbw->fetchObject(
$res );
85 $this->
output(
"found {$cur}.\n" );
87 $this->
output(
"Checking deleted edits..." );
88 $res = $dbw->select(
'archive',
'COUNT(*) AS count', $this->
userConditions(
$from,
'ar_user',
'ar_user_text' ), __METHOD__ );
89 $row = $dbw->fetchObject(
$res );
91 $this->
output(
"found {$del}.\n" );
93 # Don't count recent changes if we're not supposed to
95 $this->
output(
"Checking recent changes..." );
96 $res = $dbw->select(
'recentchanges',
'COUNT(*) AS count', $this->
userConditions(
$from,
'rc_user',
'rc_user_text' ), __METHOD__ );
97 $row = $dbw->fetchObject(
$res );
99 $this->
output(
"found {$rec}.\n" );
104 $total = $cur + $del + $rec;
105 $this->
output(
"\nTotal entries to change: {$total}\n" );
110 $this->
output(
"\nReassigning current edits..." );
111 $dbw->update(
'revision', $this->
userSpecification( $to,
'rev_user',
'rev_user_text' ),
113 $this->
output(
"done.\nReassigning deleted edits..." );
114 $dbw->update(
'archive', $this->
userSpecification( $to,
'ar_user',
'ar_user_text' ),
116 $this->
output(
"done.\n" );
117 # Update recent changes if required
119 $this->
output(
"Updating recent changes..." );
120 $dbw->update(
'recentchanges', $this->
userSpecification( $to,
'rc_user',
'rc_user_text' ),
122 $this->
output(
"done.\n" );
127 $dbw->commit( __METHOD__ );
154 return array( $idfield =>
$user->getId(), $utfield =>
$user->getName() );
167 $user->setName( $username );
171 $this->
error(
"Invalid username",
true );
Maintenance script that reassigns edits from a user or IP address to another user.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
require_once RUN_MAINTENANCE_IF_MAIN
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
hasArg( $argId=0)
Does a given argument exist?
doReassignEdits(&$from, &$to, $rc=false, $report=false)
Reassign edits from one user to another.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
initialiseUser( $username)
Initialise the user object.
__construct()
Default constructor.
static isIP( $name)
Does the string match an anonymous IPv4 address?
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
addArg( $arg, $description, $required=true)
Add some args that are needed.
userSpecification(&$user, $idfield, $utfield)
Return user specifications i.e.
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
userConditions(&$user, $idfield, $utfield)
Return the most efficient set of user conditions i.e.
hasOption( $name)
Checks to see if a particular param exists.
getArg( $argId=0, $default=null)
Get an argument.
execute()
Do the actual work.