23 $value = $request->getText( $this->mName, $this->
getDefault() ??
'' );
25 $usersArray = explode(
"\n", $value );
27 $usersArray = array_values( array_filter( $usersArray,
static function ( $username ) {
28 return trim( $username ) !==
'';
32 $normalizedUsers = [];
33 $userNameUtils = MediaWikiServices::getInstance()->getUserNameUtils();
35 foreach ( $usersArray as $user ) {
36 $canonicalUser =
false;
37 if ( IPUtils::isIPAddress( $user ) ) {
38 $parsedIPRange = IPUtils::parseRange( $user );
39 if ( !in_array( $parsedIPRange, $listOfIps ) ) {
40 $canonicalUser = IPUtils::sanitizeRange( $user );
41 $listOfIps[] = $parsedIPRange;
44 $canonicalUser = $userNameUtils->getCanonical(
45 $user, UserRigorOptions::RIGOR_NONE );
47 if ( $canonicalUser !==
false ) {
48 $normalizedUsers[] = $canonicalUser;
52 $uniqueUsers = array_unique( $normalizedUsers );
55 return implode(
"\n", $uniqueUsers );