Use CentralIdLookup instead of hardcoding for CentralAuth

Change-Id: I5b2d23588ab6b026d1a2100b9c16a74e9aefbd73
This commit is contained in:
Kunal Mehta 2015-12-08 16:54:23 -08:00
parent ea64fe4770
commit 999c53a1c3

View file

@ -28,24 +28,19 @@ class EchoUnreadWikis {
}
/**
* If CentralAuth is installed, use that. Otherwise
* assume they're using shared user tables.
* Use the user id provided by the CentralIdLookup
*
* @param User $user
* @return EchoUnreadWikis|bool
*/
public static function newFromUser( User $user ) {
if ( class_exists( 'CentralAuthUser' ) ) {
// @todo don't be CA specific (see T111302/CentralIdLookup)
$caUser = CentralAuthUser::getInstance( $user );
if ( $caUser->isAttached() ) {
return new self( $caUser->getId() );
} else {
return false;
}
$lookup = CentralIdLookup::factory();
$id = $lookup->centralIdFromLocalUser( $user, CentralIdLookup::AUDIENCE_RAW );
if ( !$id ) {
return false;
}
return new self( $user->getId() );
return new self( $id );
}
/**