28require_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..." );
86 $revQueryInfo = ActorMigration::newMigration()->getWhere( $dbw,
'rev_user', $from );
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..." );
100 $arQueryInfo = ActorMigration::newMigration()->getWhere( $dbw,
'ar_user', $from,
false );
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..." );
116 $rcQueryInfo = ActorMigration::newMigration()->getWhere( $dbw,
'rc_user', $from,
false );
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(),
145 $wgActorTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ? $to->
getName() :
''
148 ? [
'rev_user' => $from->getId() ] : [
'rev_user_text' => $from->getName() ],
154 'revision_actor_temp',
155 [
'revactor_actor' => $to->getActorId( $dbw ) ],
156 [
'revactor_actor' => $from->getActorId() ],
160 $this->
output(
"done.\nReassigning deleted edits..." );
161 $dbw->update(
'archive',
163 [ $arQueryInfo[
'conds'] ], __METHOD__ );
164 $this->
output(
"done.\n" );
165 # Update recent changes if required
167 $this->
output(
"Updating recent changes..." );
168 $dbw->update(
'recentchanges',
170 [ $rcQueryInfo[
'conds'] ], __METHOD__ );
171 $this->
output(
"done.\n" );
198 $idfield => $user->getId(),
203 $ret += [ $acfield => $user->getActorId( $dbw ) ];
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getName()
Get the script's name.
addArg( $arg, $description, $required=true)
Add some args that are needed.
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
hasArg( $argId=0)
Does a given argument exist?
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
hasOption( $name)
Checks to see if a particular param exists.
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Maintenance script that reassigns edits from a user or IP address to another user.
userSpecification(IDatabase $dbw, &$user, $idfield, $utfield, $acfield)
Return user specifications i.e.
execute()
Do the actual work.
__construct()
Default constructor.
initialiseUser( $username)
Initialise the user object.
doReassignEdits(&$from, &$to, $rc=false, $report=false)
Reassign edits from one user to another.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static isIP( $name)
Does the string match an anonymous IP address?
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
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
this hook is for auditing only or null if authentication failed before getting that far $username
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 local account $user
const MIGRATION_WRITE_BOTH
require_once RUN_MAINTENANCE_IF_MAIN