Go to the documentation of this file.
28 require_once __DIR__ .
'/Maintenance.php';
38 parent::__construct();
39 $this->
addDescription(
'Reassign edits from one user to another' );
40 $this->
addOption(
"force",
"Reassign even if the target user doesn't exist" );
41 $this->
addOption(
"norc",
"Don't update the recent changes table" );
42 $this->
addOption(
"report",
"Print out details of what would be changed, but don't update it" );
43 $this->
addArg(
'from',
'Old user to take edits from' );
44 $this->
addArg(
'to',
'New user to give edits to' );
49 # Set up the users involved
53 # If the target doesn't exist, and --force is not set, stop here
54 if ( $to->getId() || $this->
hasOption(
'force' ) ) {
58 # If reporting, and there were items, advise the user to run without --report
60 $this->
output(
"Run the script again without --report to update.\n" );
63 $ton = $to->getName();
64 $this->
error(
"User '{$ton}' not found." );
85 $this->
output(
"Checking current edits..." );
88 [
'revision' ] + $revQueryInfo[
'tables'],
90 $revQueryInfo[
'conds'],
93 $revQueryInfo[
'joins']
95 $row = $dbw->fetchObject(
$res );
97 $this->
output(
"found {$cur}.\n" );
99 $this->
output(
"Checking deleted edits..." );
102 [
'archive' ] + $arQueryInfo[
'tables'],
104 $arQueryInfo[
'conds'],
107 $arQueryInfo[
'joins']
109 $row = $dbw->fetchObject(
$res );
111 $this->
output(
"found {$del}.\n" );
113 # Don't count recent changes if we're not supposed to
115 $this->
output(
"Checking recent changes..." );
118 [
'recentchanges' ] + $rcQueryInfo[
'tables'],
120 $rcQueryInfo[
'conds'],
123 $rcQueryInfo[
'joins']
125 $row = $dbw->fetchObject(
$res );
127 $this->
output(
"found {$rec}.\n" );
132 $total = $cur + $del + $rec;
133 $this->
output(
"\nTotal entries to change: {$total}\n" );
138 $this->
output(
"\nReassigning current edits..." );
143 'rev_user' => $to->getId(),
144 'rev_user_text' => $to->getName(),
147 ? [
'rev_user' => $from->getId() ] : [
'rev_user_text' => $from->getName() ],
153 'revision_actor_temp',
154 [
'revactor_actor' => $to->getActorId( $dbw ) ],
155 [
'revactor_actor' => $from->getActorId() ],
159 $this->
output(
"done.\nReassigning deleted edits..." );
160 $dbw->update(
'archive',
162 [ $arQueryInfo[
'conds'] ], __METHOD__ );
163 $this->
output(
"done.\n" );
164 # Update recent changes if required
166 $this->
output(
"Updating recent changes..." );
167 $dbw->update(
'recentchanges',
169 [ $rcQueryInfo[
'conds'] ], __METHOD__ );
170 $this->
output(
"done.\n" );
197 $idfield =>
$user->getId(),
198 $utfield =>
$user->getName(),
202 $ret += [ $acfield =>
$user->getActorId( $dbw ) ];
Maintenance script that reassigns edits from a user or IP address to another user.
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
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addDescription( $text)
Set the description text.
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...
static newMigration()
Static constructor.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
initialiseUser( $username)
Initialise the user object.
__construct()
Default constructor.
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
static isIP( $name)
Does the string match an anonymous IP address?
userSpecification(IDatabase $dbw, &$user, $idfield, $utfield, $acfield)
Return user specifications for an UPDATE i.e.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
const SCHEMA_COMPAT_WRITE_OLD
const SCHEMA_COMPAT_WRITE_NEW
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
addArg( $arg, $description, $required=true)
Add some args that are needed.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
hasOption( $name)
Checks to see if a particular option exists.
getArg( $argId=0, $default=null)
Get an argument.
this hook is for auditing only or null if authentication failed before getting that far $username
execute()
Do the actual work.
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.