renameUserFactory = $renameUserFactory; $this->userFactory = $userFactory; } public function run() { $oldName = $this->params['oldname']; $newName = $this->params['newname']; $uid = $this->params['uid']; $performerUid = $this->params['performer']; $reason = $this->params['reason']; $movePages = $this->params['movePages'] ?? true; $suppressRedirect = $this->params['suppressRedirect'] ?? false; $user = $this->userFactory->newFromId( $uid ); $performer = $this->userFactory->newFromId( $performerUid ); $logger = LoggerFactory::getInstance( 'RenameUser' ); // Check if this wiki has the same shared user database as the trigger wiki. if ( !$this->userFactory->isUserTableShared() ) { return true; } if ( $user->getName() !== $newName ) { $logger->info( "User to be renamed from $oldName to $newName does not have the expected name, skipping" ); return true; } // Do the rename $rename = $this->renameUserFactory->newDerivedRenameUser( $performer, $uid, $oldName, $newName, $reason, [ 'movePages' => $movePages, 'suppressRedirect' => $suppressRedirect ] ); $status = $rename->renameLocal(); if ( !$status->isGood() ) { $logger->error( "Cannot finish derived local user rename from $oldName to $newName: $status" ); } return $status->isOK(); } }