Go to the documentation of this file.
22 use Wikimedia\ObjectFactory;
53 if ( !array_key_exists(
$providerId, self::$instances ) ) {
73 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
74 throw new MWException( __METHOD__ .
' may only be called from unit tests!' );
76 self::$instances = [];
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
173 $idToName = array_fill_keys( $ids,
false );
175 $names = array_unique( $names );
176 $names = array_filter( $names,
function (
$name ) {
180 return array_values( $names );
194 $name, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
197 return $nameToId[
$name];
209 array $names, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
211 $nameToId = array_fill_keys( $names,
false );
213 $ids = array_unique( $ids );
214 $ids = array_filter( $ids,
function ( $id ) {
215 return $id !==
false;
218 return array_values( $ids );
233 $id, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
257 User $user, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
namesFromCentralIds(array $ids, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a an array of central user IDs, return the (local) user names.
centralIdFromLocalUser(User $user, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a local User object, return the central ID.
nameFromCentralId( $id, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a central user ID, return the (local) user name.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Interface for database access objects.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
string $wgCentralIdLookupProvider
Central ID lookup provider to use by default.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
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))
centralIdsFromNames(array $names, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given an array of (local) user names, return the central IDs.
Allows to change the fields on the form that will be generated $name
static resetCache()
Reset internal cache for unit testing.
lookupCentralIds(array $idToName, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given central user IDs, return the (local) user names.
static CentralIdLookup[] $instances
$wgCentralIdLookupProviders
Central ID lookup providers Key is the provider ID, value is a specification for ObjectFactory.
centralIdFromName( $name, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a (local) user name, return the central ID.
lookupUserNames(array $nameToId, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given (local) user names, return the central IDs.
The CentralIdLookup service allows for connecting local users with cluster-wide IDs.
isAttached(User $user, $wikiId=null)
Check that a User is attached on the specified wiki.
checkAudience( $audience)
Check that the "audience" parameter is valid.
static factory( $providerId=null)
Fetch a CentralIdLookup.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.
localUserFromCentralId( $id, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given a central user ID, return a local User object.