Page MenuHomePhabricator

Refactor $user->getName() to distinguish between temporary and registered users
Closed, DeclinedPublic

Description

  • Using ->getName() without checking ->isTemp() will not distinguish between temporary and registered users. The ->getName() method will return the unique identifier for temporary users(which is different from their IP address.) making the result of this query: $ip == $user->getName() false for temporary users. This may not be useful for generating links or displaying labels. The code should now add another check for $user->isTemp(); to treat temp users differently from registered users or anon users.

See snippet below :

src/CheckUser/Pagers/AbstractCheckUserPager.php

			$flags[] = $this->getBlockFlag( $block );
		} elseif (
			$ip == $user->getName() &&
			ExtensionRegistry::getInstance()->isLoaded( 'GlobalBlocking' ) &&
			GlobalBlocking::getUserBlock(

Example

if ( $user->isTemp() ) {
    // do Something for temporary users
    $name = $user->getName();
} elseif ( $user->isNamed() ) {
    // Use the user name for registered users
    $name = $user->getName();
} else {
    // Use the IP address for anonymous users
    $name = $ip;
}

Event Timeline

Same question asked at T337234#8874349 applies here. If temporary accounts will be able to be "locked" as can be done for registered users and also not be blocked like IPs can be here, then this code shouldn't need an update.