21 private readonly
string $usernamePrefix;
26 private $triedCreations = [];
33 string $usernamePrefix,
34 private readonly
bool $assignKnownUsers,
36 $this->usernamePrefix = rtrim( $usernamePrefix,
':>' );
47 $pos = strpos( $userName,
'>' );
49 if ( $pos !==
false ) {
50 $iw = explode(
':', substr( $userName, 0, $pos ) );
51 $firstIw = array_shift( $iw );
52 $interwikiLookup = $services->getInterwikiLookup();
53 if ( $interwikiLookup->isValidInterwiki( $firstIw ) ) {
54 $title = $services->getNamespaceInfo()->getCanonicalName(
NS_USER ) .
55 ':' . substr( $userName, $pos + 1 );
57 $title = implode(
':', $iw ) .
':' . $title;
65 $services->getUserNameUtils()->isIP( $userName )
66 || $services->getUserNameUtils()->isValidIPRange( $userName )
67 || $services->getUserNameUtils()->isValid( $userName )
93 $userNameUtils = $services->getUserNameUtils();
98 if ( $this->assignKnownUsers ) {
99 $userIdentityLookup = $services->getUserIdentityLookup();
100 $userIdentity = $userIdentityLookup->getUserIdentityByName( $name );
101 if ( $userIdentity && $userIdentity->isRegistered() ) {
106 if ( !isset( $this->triedCreations[$name] ) ) {
107 $this->triedCreations[$name] =
true;
108 if ( !(
new HookRunner( $services->getHookContainer() ) )->onImportHandleUnknownUser( $name ) ) {
109 $userIdentity = $userIdentityLookup->getUserIdentityByName( $name, IDBAccessObject::READ_LATEST );
110 if ( $userIdentity && $userIdentity->isRegistered() ) {
127 return substr( $this->usernamePrefix .
'>' . $name, 0, 255 );
137 return str_contains( $username,
'>' );
147 if ( !self::isExternal( $username ) ) {
151 return substr( $username, strpos( $username,
'>' ) + 1 );
162 if ( !self::isExternal( $username ) ) {
166 return substr( $username, 0, strpos( $username,
'>' ) );
172class_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,...