MediaWiki  master
LocalIdLookup Class Reference

A CentralIdLookup provider that just uses local IDs. More...

Inheritance diagram for LocalIdLookup:
Collaboration diagram for LocalIdLookup:

Public Member Functions

 __construct (Config $config, ILoadBalancer $loadBalancer)
 
 isAttached (UserIdentity $user, $wikiId=UserIdentity::LOCAL)
 Check that a user is attached on the specified wiki. More...
 
 lookupCentralIds (array $idToName, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
 Given central user IDs, return the (local) user names. More...
 
 lookupUserNames (array $nameToId, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
 Given (local) user names, return the central IDs. More...
 
- Public Member Functions inherited from CentralIdLookup
 centralIdFromLocalUser (UserIdentity $user, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
 Given a local UserIdentity object, return the central ID. More...
 
 centralIdFromName ( $name, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
 Given a (local) user name, return the central ID. More...
 
 centralIdsFromNames (array $names, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
 Given an array of (local) user names, return the central IDs. More...
 
 getProviderId ()
 Get the provider id. More...
 
 init (string $providerId, UserIdentityLookup $userIdentityLookup)
 Initialize the provider. More...
 
 localUserFromCentralId ( $id, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
 Given a central user ID, return a local user object. More...
 
 nameFromCentralId ( $id, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
 Given a central user ID, return the (local) user name. More...
 
 namesFromCentralIds (array $ids, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
 Given a an array of central user IDs, return the (local) user names. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CentralIdLookup
static factory ( $providerId=null)
 Fetch a CentralIdLookup. More...
 
static factoryNonLocal ()
 Returns a CentralIdLookup that is guaranteed to be non-local. More...
 
- Public Attributes inherited from CentralIdLookup
const AUDIENCE_PUBLIC = 1
 
const AUDIENCE_RAW = 2
 
- Public Attributes inherited from IDBAccessObject
const READ_NONE = -1
 Constants for object loading bitfield flags (higher => higher QoS) More...
 
- Protected Member Functions inherited from CentralIdLookup
 checkAudience ( $audience)
 Check that the "audience" parameter is valid. More...
 

Detailed Description

A CentralIdLookup provider that just uses local IDs.

Useful if the wiki isn't part of a cluster or you're using shared user tables.

Note
Shared user table support expects that all wikis involved have $wgSharedDB and $wgSharedTables set, and that all wikis involved in the sharing are listed in $wgLocalDatabases, and that no wikis not involved in the sharing are listed in $wgLocalDatabases.
Since
1.27

Definition at line 37 of file LocalIdLookup.php.

Constructor & Destructor Documentation

◆ __construct()

LocalIdLookup::__construct ( Config  $config,
ILoadBalancer  $loadBalancer 
)
Parameters
Config$config
ILoadBalancer$loadBalancer

Definition at line 55 of file LocalIdLookup.php.

References Config\get().

Member Function Documentation

◆ isAttached()

LocalIdLookup::isAttached ( UserIdentity  $user,
  $wikiId = UserIdentity::LOCAL 
)

Check that a user is attached on the specified wiki.

If unattached local accounts don't exist in your extension, this comes down to a check whether the central account exists at all and that $wikiId is using the same central database.

Parameters
UserIdentity$user
string | false$wikiIdWiki to check attachment status. If false, check the current wiki.
Returns
bool

Reimplemented from CentralIdLookup.

Definition at line 65 of file LocalIdLookup.php.

◆ lookupCentralIds()

LocalIdLookup::lookupCentralIds ( array  $idToName,
  $audience = self::AUDIENCE_PUBLIC,
  $flags = self::READ_NORMAL 
)

Given central user IDs, return the (local) user names.

Note
There's no requirement that the user names actually exist locally, or if they do that they're actually attached to the central account.
Parameters
array$idToNameArray with keys being central user IDs
int | Authority$audienceOne of the audience constants, or a specific authority
int$flagsIDBAccessObject read flags
Returns
string[] Copy of $idToName with values set to user names (or empty-string if the user exists but $audience lacks the rights needed to see it). IDs not corresponding to a user are unchanged.

Reimplemented from CentralIdLookup.

Definition at line 83 of file LocalIdLookup.php.

◆ lookupUserNames()

LocalIdLookup::lookupUserNames ( array  $nameToId,
  $audience = self::AUDIENCE_PUBLIC,
  $flags = self::READ_NORMAL 
)

Given (local) user names, return the central IDs.

Note
There's no requirement that the user names actually exist locally, or if they do that they're actually attached to the central account.
Parameters
array$nameToIdArray with keys being canonicalized user names
int | Authority$audienceOne of the audience constants, or a specific authority
int$flagsIDBAccessObject read flags
Returns
int[] Copy of $nameToId with values set to central IDs. Names not corresponding to a user (or $audience lacks the rights needed to see it) are unchanged.

Reimplemented from CentralIdLookup.

Definition at line 113 of file LocalIdLookup.php.


The documentation for this class was generated from the following file: