22use Wikimedia\ObjectFactory;
46 public static function factory( $providerId =
null ) {
59 $provider->providerId = $providerId;
60 self::$instances[$providerId] = $provider;
73 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
74 throw new MWException( __METHOD__ .
' may only be called from unit tests!' );
76 self::$instances = [];
80 return $this->providerId;
90 if ( $audience instanceof
User ) {
93 if ( $audience === self::AUDIENCE_PUBLIC ) {
96 if ( $audience === self::AUDIENCE_RAW ) {
99 throw new InvalidArgumentException(
'Invalid audience' );
127 array $idToName, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
142 array $nameToId, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
156 $id, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
159 return $idToName[$id];
171 array $ids, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
177 return $name !==
false && $name !==
'';
194 $name, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
196 $nameToId = $this->
lookupUserNames( [ $name => 0 ], $audience, $flags );
197 return $nameToId[
$name];
209 array $names, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
215 return $id !==
false;
233 $id, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
236 if ( $name !==
null && $name !==
'' ) {
238 if ( $user && $user->getId() && $this->isAttached( $user ) ) {
257 User $user, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
string $wgCentralIdLookupProvider
Central ID lookup provider to use by default.
$wgCentralIdLookupProviders
Central ID lookup providers Key is the provider ID, value is a specification for ObjectFactory.
The CentralIdLookup service allows for connecting local users with cluster-wide IDs.
static resetCache()
Reset internal cache for unit testing.
static factory( $providerId=null)
Fetch a CentralIdLookup.
nameFromCentralId( $id, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a central user ID, return the (local) user name.
isAttached(User $user, $wikiId=null)
Check that a User is attached on the specified wiki.
centralIdFromLocalUser(User $user, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a local User object, return the central ID.
static CentralIdLookup[] $instances
lookupCentralIds(array $idToName, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given central user IDs, return the (local) user names.
centralIdFromName( $name, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a (local) user name, return the central ID.
namesFromCentralIds(array $ids, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a an array of central user IDs, return the (local) user names.
centralIdsFromNames(array $names, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given an array of (local) user names, return the central IDs.
lookupUserNames(array $nameToId, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given (local) user names, return the central IDs.
checkAudience( $audience)
Check that the "audience" parameter is valid.
localUserFromCentralId( $id, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a central user ID, return a local User object.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Allows to change the fields on the form that will be generated $name
return true to allow those checks to and false if checking is done & $user
Interface for database access objects.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))