X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fuser%2FExternalUserNames.php;h=41facc707d958143cf891ce6d0a11d48d5e21ea4;hb=3020d27638add607e9d86622652221c3729faf87;hp=f953b144d8051682504caeebd2807b08dbc6591a;hpb=a6abe2ad7a1ed2c8dd29f35a9f6c40f85e12b7ab;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/user/ExternalUserNames.php b/includes/user/ExternalUserNames.php index f953b144d8..41facc707d 100644 --- a/includes/user/ExternalUserNames.php +++ b/includes/user/ExternalUserNames.php @@ -27,8 +27,20 @@ use MediaWiki\MediaWikiServices; * @since 1.31 */ class ExternalUserNames { + + /** + * @var string + */ private $usernamePrefix = 'imported'; + + /** + * @var bool + */ private $assignKnownUsers = false; + + /** + * @var bool[] + */ private $triedCreations = []; /** @@ -52,9 +64,11 @@ class ExternalUserNames { if ( $pos !== false ) { $iw = explode( ':', substr( $userName, 0, $pos ) ); $firstIw = array_shift( $iw ); - $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup(); + $services = MediaWikiServices::getInstance(); + $interwikiLookup = $services->getInterwikiLookup(); if ( $interwikiLookup->isValidInterwiki( $firstIw ) ) { - $title = MWNamespace::getCanonicalName( NS_USER ) . ':' . substr( $userName, $pos + 1 ); + $title = $services->getNamespaceInfo()->getCanonicalName( NS_USER ) . + ':' . substr( $userName, $pos + 1 ); if ( $iw ) { $title = implode( ':', $iw ) . ':' . $title; } @@ -69,8 +83,16 @@ class ExternalUserNames { /** * Add an interwiki prefix to the username, if appropriate * - * @param string $name Name being imported - * @return string Name, possibly with the prefix prepended. + * This method does have a side-effect on SUL (single user login) wikis: Calling this calls the + * ImportHandleUnknownUser hook from the CentralAuth extension, which assigns a local ID to the + * global user name, if possible. No prefix is applied if this is successful. + * + * @see https://meta.wikimedia.org/wiki/Help:Unified_login + * @see https://www.mediawiki.org/wiki/Manual:Hooks/ImportHandleUnknownUser + * + * @param string $name + * @return string Either the unchanged username if it's a known local user (or not a valid + * username), otherwise the name with the prefix prepended. */ public function applyPrefix( $name ) { if ( !User::isUsableName( $name ) ) { @@ -99,8 +121,8 @@ class ExternalUserNames { /** * Add an interwiki prefix to the username regardless of circumstances * - * @param string $name Name being imported - * @return string Name + * @param string $name + * @return string Prefixed username, using ">" as separator */ public function addPrefix( $name ) { return substr( $this->usernamePrefix . '>' . $name, 0, 255 );