MediaWiki
master
|
UserNameUtils service. More...
Public Member Functions | |
__construct (ServiceOptions $options, Language $contentLang, LoggerInterface $logger, TitleParser $titleParser, ITextFormatter $textFormatter, HookContainer $hookContainer, TempUserConfig $tempUserConfig) | |
getCanonical (string $name, string $validate=self::RIGOR_VALID) | |
Given unvalidated user input, return a canonical username, or false if the username is invalid. More... | |
getTempPlaceholder () | |
Get a placeholder name for a temporary user before serial acquisition. More... | |
isCreatable (string $name) | |
Usernames which fail to pass this function will be blocked from new account registrations, but may be used internally either by batch processes or by user accounts which have already been created. More... | |
isIP (string $name) | |
Does the string match an anonymous IP address? More... | |
isTemp (string $name) | |
Does the username indicate a temporary user? More... | |
isTempReserved (string $name) | |
Is the username uncreatable due to it being reserved by the temp username system? Note that unlike isTemp(), this does not imply that a user having this name is an actual temp account. More... | |
isUsable (string $name) | |
Usernames which fail to pass this function will be blocked from user login and new account registrations, but may be used internally by batch processes. More... | |
isValid (string $name) | |
Is the input a valid username? More... | |
isValidIPRange (string $range) | |
Wrapper for IPUtils::isValidRange. More... | |
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
MediaWiki\User\UserNameUtils::__construct | ( | ServiceOptions | $options, |
Language | $contentLang, | ||
LoggerInterface | $logger, | ||
TitleParser | $titleParser, | ||
ITextFormatter | $textFormatter, | ||
HookContainer | $hookContainer, | ||
TempUserConfig | $tempUserConfig | ||
) |
ServiceOptions | $options | |
Language | $contentLang | |
LoggerInterface | $logger | |
TitleParser | $titleParser | |
ITextFormatter | $textFormatter | the text formatter for the current content language |
HookContainer | $hookContainer | |
TempUserConfig | $tempUserConfig |
Definition at line 106 of file UserNameUtils.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions().
MediaWiki\User\UserNameUtils::getCanonical | ( | string | $name, |
string | $validate = self::RIGOR_VALID |
||
) |
Given unvalidated user input, return a canonical username, or false if the username is invalid.
string | $name | User input |
string | $validate | Type of validation to use Use of public constants RIGOR_* is preferred
|
InvalidArgumentException |
Definition at line 281 of file UserNameUtils.php.
References NS_USER.
MediaWiki\User\UserNameUtils::getTempPlaceholder | ( | ) |
Get a placeholder name for a temporary user before serial acquisition.
Definition at line 404 of file UserNameUtils.php.
MediaWiki\User\UserNameUtils::isCreatable | ( | string | $name | ) |
Usernames which fail to pass this function will be blocked from new account registrations, but may be used internally either by batch processes or by user accounts which have already been created.
Additional preventions may be added here rather than in isValid() to avoid disrupting existing accounts.
string | $name | String to match |
Definition at line 235 of file UserNameUtils.php.
MediaWiki\User\UserNameUtils::isIP | ( | string | $name | ) |
Does the string match an anonymous IP address?
This function exists for username validation, in order to reject usernames which are similar in form to IP addresses. Strings such as 300.300.300.300 will return true because it looks like an IP address, despite not being strictly valid.
We match "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.xxx" as an anonymous IP address because the usemod software would "cloak" anonymous IP addresses like this, if we allowed accounts like this to be created new users could get the old edits of these anonymous users.
This does //not// match IPv6 ranges (T239527)
string | $name | Name to check |
Definition at line 357 of file UserNameUtils.php.
Referenced by MediaWiki\Pager\ImageListPager\__construct().
MediaWiki\User\UserNameUtils::isTemp | ( | string | $name | ) |
Does the username indicate a temporary user?
string | $name |
Definition at line 380 of file UserNameUtils.php.
MediaWiki\User\UserNameUtils::isTempReserved | ( | string | $name | ) |
Is the username uncreatable due to it being reserved by the temp username system? Note that unlike isTemp(), this does not imply that a user having this name is an actual temp account.
This should only be used to deny account creation.
string | $name |
Definition at line 394 of file UserNameUtils.php.
MediaWiki\User\UserNameUtils::isUsable | ( | string | $name | ) |
Usernames which fail to pass this function will be blocked from user login and new account registrations, but may be used internally by batch processes.
If an account already exists in this form, login will be blocked by a failure to pass this function.
string | $name | Name to match |
Definition at line 189 of file UserNameUtils.php.
MediaWiki\User\UserNameUtils::isValid | ( | string | $name | ) |
Is the input a valid username?
Checks if the input is a valid username, we don't want an empty string, an IP address, anything that contains slashes (would mess up subpages), is longer than the maximum allowed username size or doesn't begin with a capital letter.
string | $name | Name to match |
Definition at line 136 of file UserNameUtils.php.
MediaWiki\User\UserNameUtils::isValidIPRange | ( | string | $range | ) |
Wrapper for IPUtils::isValidRange.
string | $range | Range to check |
Definition at line 369 of file UserNameUtils.php.
const MediaWiki\User\UserNameUtils::CONSTRUCTOR_OPTIONS |
Definition at line 49 of file UserNameUtils.php.