Go to the documentation of this file.
9 parent::__construct(
'Renameuser',
'renameuser' );
32 $out->addWikiMsg(
'renameuser-summary' );
35 if ( !
$user->isAllowed(
'renameuser' ) ) {
43 if (
$user->isBlocked() ) {
50 $showBlockLog =
$request->getBool(
'submit-showBlockLog' );
51 $usernames = explode(
'/', $par, 2 );
52 $oldnamePar = trim( str_replace(
'_',
' ',
$request->getText(
'oldusername', $usernames[0] ) ) );
54 $newnamePar = $usernames[1] ??
null;
55 $newnamePar = trim( str_replace(
'_',
' ',
$request->getText(
'newusername', $newnamePar ) ) );
59 $oun = is_object( $oldusername ) ? $oldusername->getText() :
'';
60 $nun = is_object( $newusername ) ? $newusername->getText() :
'';
61 $token =
$user->getEditToken();
62 $reason =
$request->getText(
'reason' );
65 $suppress_checked =
$request->getCheck(
'suppressredirect' );
68 if ( $oun && $nun && !
$request->getCheck(
'confirmaction' ) ) {
69 Hooks::run(
'RenameUserWarning', [ $oun, $nun, &$warnings ] );
82 <td class='mw-label'>" .
85 <td class='mw-input'>" .
86 Xml::input(
'oldusername', 20, $oun, [
'type' =>
'text',
'tabindex' =>
'1' ] ) .
' ' .
90 <td class='mw-label'>" .
93 <td class='mw-input'>" .
94 Xml::input(
'newusername', 20, $nun, [
'type' =>
'text',
'tabindex' =>
'2' ] ) .
98 <td class='mw-label'>" .
101 <td class='mw-input'>" .
106 [
'type' =>
'text',
'tabindex' =>
'3',
'maxlength' => 255 ]
111 if (
$user->isAllowed(
'move' ) ) {
116 <td class='mw-input'>" .
118 $move_checked, [
'tabindex' =>
'4' ] ) .
123 if (
$user->isAllowed(
'suppressredirect' ) ) {
128 <td class='mw-input'>" .
130 $this->
msg(
'renameusersuppress' )->
text(),
134 [
'tabindex' =>
'5' ]
143 foreach ( $warnings
as $warning ) {
144 $warningsHtml[] = is_array( $warning ) ?
145 $this->
msg( $warning[0] )->rawParams( array_slice( $warning, 1 ) )->escaped() :
146 $this->
msg( $warning )->escaped();
151 <td class='mw-label'>" . $this->
msg(
'renameuserwarnings' )->escaped() .
"
153 <td class='mw-input'>" .
154 '<ul class="error"><li>' .
155 implode(
'</li><li>', $warningsHtml ) .
'</li></ul>' .
163 <td class='mw-input'>" .
165 $this->
msg(
'renameuserconfirm' )->
text(),
169 [
'tabindex' =>
'6' ]
179 <td class='mw-submit'>" .
181 $this->
msg(
'renameusersubmit' )->
text(),
190 $this->
msg(
'renameuser-submit-blocklog' )->
text(),
192 'name' =>
'submit-showBlockLog',
193 'id' =>
'submit-showBlockLog',
201 Html::hidden(
'token', $token ) .
206 if ( $showBlockLog && is_object( $oldusername ) ) {
212 if (
$request->getText(
'token' ) ===
'' ) {
213 # They probably haven't even submitted the form, so don't go further.
215 } elseif ( $warnings ) {
216 # Let user read warnings
219 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
'renameuser-error-request' );
222 } elseif ( !is_object( $oldusername ) ) {
223 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
224 [
'renameusererrorinvalid',
$request->getText(
'oldusername' ) ] );
227 } elseif ( !is_object( $newusername ) ) {
228 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
229 [
'renameusererrorinvalid',
$request->getText(
'newusername' ) ] );
232 } elseif ( $oldusername->getText() === $newusername->getText() ) {
233 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
'renameuser-error-same-user' );
243 if ( !is_object( $olduser ) ) {
244 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
245 [
'renameusererrorinvalid', $oldusername->getText() ] );
250 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
251 [
'renameusererrorinvalid', $newusername->getText() ] );
258 if ( $oldusername->getText() !==
$wgContLang->ucfirst( $oldusername->getText() ) ) {
261 $uid =
$dbr->selectField(
'user',
'user_id',
262 [
'user_name' => $oldusername->getText() ],
264 if ( $uid ===
false ) {
269 $uid = $olduser->idForName();
275 $uid = $olduser->idForName();
279 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
280 [
'renameusererrordoesnotexist', $oldusername->getText() ] );
285 if ( $newuser->idForName() !== 0 ) {
286 $out->wrapWikiMsg(
"<div class=\"errorbox\">$1</div>",
287 [
'renameusererrorexists', $newusername->getText() ] );
295 [ $uid, $oldusername->getText(), $newusername->getText() ]
302 $oldusername->getText(),
303 $newusername->getText(),
306 [
'reason' => $reason ]
308 if ( !$rename->rename() ) {
314 if (
$user->getId() === $uid ) {
315 $user->setName( $newusername->getText() );
319 if (
$request->getCheck(
'movepages' ) &&
$user->isAllowed(
'move' ) ) {
322 $pages =
$dbr->select(
324 [
'page_namespace',
'page_title' ],
328 'page_title ' .
$dbr->buildLike( $oldusername->getDBkey() .
'/',
$dbr->anyString() ),
329 'page_title = ' .
$dbr->addQuotes( $oldusername->getDBkey() ),
335 $suppressRedirect =
false;
337 if (
$request->getCheck(
'suppressredirect' ) &&
$user->isAllowed(
'suppressredirect' ) ) {
338 $suppressRedirect =
true;
343 foreach ( $pages
as $row ) {
346 preg_replace(
'!^[^/]+!', $newusername->getDBkey(), $row->page_title ) );
348 $movePage =
new MovePage( $oldPage, $newPage );
349 $validMoveStatus = $movePage->isValidMove();
351 # Do not autodelete or anything, title must not exist
352 if ( $newPage->exists() && !$validMoveStatus->isOK() ) {
356 [
'class' =>
'mw-renameuser-pe' ],
357 $this->
msg(
'renameuser-page-exists' )->rawParams(
$link )->escaped()
360 $logReason = $this->
msg(
361 'renameuser-move-log', $oldusername->getText(), $newusername->getText()
362 )->inContentLanguage()->text();
364 $moveStatus = $movePage->move(
$user, $logReason, !$suppressRedirect );
366 if ( $moveStatus->isOK() ) {
367 # oldPage is not known in case of redirect suppression
368 $oldLink =
$linkRenderer->makeLink( $oldPage,
null, [], [
'redirect' =>
'no' ] );
370 # newPage is always known because the move was successful
375 [
'class' =>
'mw-renameuser-pm' ],
376 $this->
msg(
'renameuser-page-moved' )->rawParams( $oldLink, $newLink )->escaped()
382 'li', [
'class' =>
'mw-renameuser-pu' ],
383 $this->
msg(
'renameuser-page-unmoved' )->rawParams( $oldLink, $newLink )->escaped()
389 $out->addHTML( Html::rawElement(
'ul', [],
$output ) );
394 $out->wrapWikiMsg(
"<div class=\"successbox\">$1</div><br style=\"clear:both\" />",
395 [
'renameusersuccess', $oldusername->getText(), $newusername->getText() ] );
404 # Show relevant lines from the logs:
406 $out->addHTML(
Xml::element(
'h2',
null, $logPage->getName()->text() ) .
"\n" );
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
getPageTitle( $subpage=false)
Get a self-referential title object.
return true to allow those checks to and false if checking is done & $user
msg( $key)
Wrapper around wfMessage that sets the current context.
processing should stop and the error should be shown to the user * false
Show an error when the user tries to do something whilst blocked.
getOutput()
Get the OutputPage being used for this instance.
doesWrites()
Indicates whether this special page may perform database writes.
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
wfReadOnly()
Check whether the wiki is in read-only mode.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Show an error when a user tries to do something they do not have the necessary permissions for.
static openElement( $element, $attribs=null)
This opens an XML element.
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
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Class which performs the actual renaming of users.
Handles the backend logic of moving a page from one title to another.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Class to simplify the use of log pages.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
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 also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Parent class for all special pages.
getRequest()
Get the WebRequest being used for this instance.
Special page that allows authorised users to rename user accounts.
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
static closeElement( $element)
Shortcut to close an XML element.
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
usually copyright or history_copyright This message must be in HTML not wikitext & $link
showLogExtract( $username, $type, &$out)
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
MediaWiki Linker LinkRenderer null $linkRenderer
execute( $par)
Show the special page.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
this hook is for auditing only or null if authentication failed before getting that far $username
static isCreatableName( $name)
Usernames which fail to pass this function will be blocked from new account registrations,...
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.