40 private $usernamePrefix;
45 private $assignKnownUsers;
50 private $triedCreations = [];
56 public function __construct( $usernamePrefix, $assignKnownUsers ) {
57 $this->usernamePrefix = rtrim( (
string)$usernamePrefix,
':>' );
58 $this->assignKnownUsers = (bool)$assignKnownUsers;
69 $pos = strpos( $userName,
'>' );
71 if ( $pos !==
false ) {
72 $iw = explode(
':', substr( $userName, 0, $pos ) );
73 $firstIw = array_shift( $iw );
74 $interwikiLookup = $services->getInterwikiLookup();
75 if ( $interwikiLookup->isValidInterwiki( $firstIw ) ) {
76 $title = $services->getNamespaceInfo()->getCanonicalName(
NS_USER ) .
77 ':' . substr( $userName, $pos + 1 );
79 $title = implode(
':', $iw ) .
':' . $title;
87 $services->getUserNameUtils()->isIP( $userName )
88 || $services->getUserNameUtils()->isValidIPRange( $userName )
89 || $services->getUserNameUtils()->isValid( $userName )
115 $userNameUtils = $services->getUserNameUtils();
116 if ( $userNameUtils->getCanonical( $name, UserRigorOptions::RIGOR_USABLE ) ===
false ) {
120 if ( $this->assignKnownUsers ) {
121 $userIdentityLookup = $services->getUserIdentityLookup();
122 $userIdentity = $userIdentityLookup->getUserIdentityByName( $name );
123 if ( $userIdentity && $userIdentity->isRegistered() ) {
128 if ( !isset( $this->triedCreations[$name] ) ) {
129 $this->triedCreations[$name] =
true;
130 if ( !(
new HookRunner( $services->getHookContainer() ) )->onImportHandleUnknownUser( $name ) ) {
131 $userIdentity = $userIdentityLookup->getUserIdentityByName( $name, IDBAccessObject::READ_LATEST );
132 if ( $userIdentity && $userIdentity->isRegistered() ) {
149 return substr( $this->usernamePrefix .
'>' . $name, 0, 255 );
159 return str_contains( $username,
'>' );
169 if ( !self::isExternal( $username ) ) {
173 return substr( $username, strpos( $username,
'>' ) + 1 );
182 class_alias( ExternalUserNames::class,
'ExternalUserNames' );
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Interface for database access objects.