35 private string $usernamePrefix;
36 private bool $assignKnownUsers;
41 private $triedCreations = [];
47 public function __construct( $usernamePrefix, $assignKnownUsers ) {
48 $this->usernamePrefix = rtrim( (
string)$usernamePrefix,
':>' );
49 $this->assignKnownUsers = (bool)$assignKnownUsers;
60 $pos = strpos( $userName,
'>' );
62 if ( $pos !==
false ) {
63 $iw = explode(
':', substr( $userName, 0, $pos ) );
64 $firstIw = array_shift( $iw );
65 $interwikiLookup = $services->getInterwikiLookup();
66 if ( $interwikiLookup->isValidInterwiki( $firstIw ) ) {
67 $title = $services->getNamespaceInfo()->getCanonicalName(
NS_USER ) .
68 ':' . substr( $userName, $pos + 1 );
70 $title = implode(
':', $iw ) .
':' . $title;
72 return Title::makeTitle(
NS_MAIN, $title,
'', $firstIw );
78 $services->getUserNameUtils()->isIP( $userName )
79 || $services->getUserNameUtils()->isValidIPRange( $userName )
80 || $services->getUserNameUtils()->isValid( $userName )
106 $userNameUtils = $services->getUserNameUtils();
111 if ( $this->assignKnownUsers ) {
112 $userIdentityLookup = $services->getUserIdentityLookup();
113 $userIdentity = $userIdentityLookup->getUserIdentityByName( $name );
114 if ( $userIdentity && $userIdentity->isRegistered() ) {
119 if ( !isset( $this->triedCreations[$name] ) ) {
120 $this->triedCreations[$name] =
true;
121 if ( !(
new HookRunner( $services->getHookContainer() ) )->onImportHandleUnknownUser( $name ) ) {
122 $userIdentity = $userIdentityLookup->getUserIdentityByName( $name, IDBAccessObject::READ_LATEST );
123 if ( $userIdentity && $userIdentity->isRegistered() ) {
140 return substr( $this->usernamePrefix .
'>' . $name, 0, 255 );
150 return str_contains( $username,
'>' );
160 if ( !self::isExternal( $username ) ) {
164 return substr( $username, strpos( $username,
'>' ) + 1 );
170class_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,...