MediaWiki REL1_31
|
The CentralIdLookup service allows for connecting local users with cluster-wide IDs. More...
Public Member Functions | |
centralIdFromLocalUser (User $user, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL) | |
Given a local User object, return the central ID. | |
centralIdFromName ( $name, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL) | |
Given a (local) user name, return the central ID. | |
centralIdsFromNames (array $names, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL) | |
Given an array of (local) user names, return the central IDs. | |
getProviderId () | |
isAttached (User $user, $wikiId=null) | |
Check that a User is attached on the specified wiki. | |
localUserFromCentralId ( $id, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL) | |
Given a central user ID, return a local User object. | |
lookupCentralIds (array $idToName, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL) | |
Given central user IDs, return the (local) user names. | |
lookupUserNames (array $nameToId, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL) | |
Given (local) user names, return the central IDs. | |
nameFromCentralId ( $id, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL) | |
Given a central user ID, return the (local) user name. | |
namesFromCentralIds (array $ids, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL) | |
Given a an array of central user IDs, return the (local) user names. | |
Static Public Member Functions | |
static | factory ( $providerId=null) |
Fetch a CentralIdLookup. | |
static | factoryNonLocal () |
Returns a CentralIdLookup that is guaranteed to be non-local. | |
static | resetCache () |
Reset internal cache for unit testing. | |
Public Attributes | |
const | AUDIENCE_PUBLIC = 1 |
const | AUDIENCE_RAW = 2 |
Public Attributes inherited from IDBAccessObject | |
const | READ_LOCKING = 3 |
Constants for object loading bitfield flags (higher => higher QoS) | |
const | READ_NONE = -1 |
Protected Member Functions | |
checkAudience ( $audience) | |
Check that the "audience" parameter is valid. | |
Private Attributes | |
string | $providerId |
Static Private Attributes | |
static CentralIdLookup[] | $instances = [] |
The CentralIdLookup service allows for connecting local users with cluster-wide IDs.
Definition at line 30 of file CentralIdLookup.php.
CentralIdLookup::centralIdFromLocalUser | ( | User | $user, |
$audience = self::AUDIENCE_PUBLIC, | |||
$flags = self::READ_NORMAL ) |
Given a local User object, return the central ID.
User | $user | Local user |
int | User | $audience | One of the audience constants, or a specific user |
int | $flags | IDBAccessObject read flags |
Definition at line 285 of file CentralIdLookup.php.
References centralIdFromName(), and isAttached().
CentralIdLookup::centralIdFromName | ( | $name, | |
$audience = self::AUDIENCE_PUBLIC, | |||
$flags = self::READ_NORMAL ) |
Given a (local) user name, return the central ID.
string | $name | Canonicalized user name |
int | User | $audience | One of the audience constants, or a specific user |
int | $flags | IDBAccessObject read flags |
Definition at line 222 of file CentralIdLookup.php.
References $name, and lookupUserNames().
Referenced by centralIdFromLocalUser().
CentralIdLookup::centralIdsFromNames | ( | array | $names, |
$audience = self::AUDIENCE_PUBLIC, | |||
$flags = self::READ_NORMAL ) |
Given an array of (local) user names, return the central IDs.
string[] | $names | Canonicalized user names |
int | User | $audience | One of the audience constants, or a specific user |
int | $flags | IDBAccessObject read flags |
Definition at line 237 of file CentralIdLookup.php.
References lookupUserNames().
|
protected |
Check that the "audience" parameter is valid.
int | User | $audience | One of the audience constants, or a specific user |
InvalidArgumentException |
Definition at line 118 of file CentralIdLookup.php.
Referenced by LocalIdLookup\lookupCentralIds(), and LocalIdLookup\lookupUserNames().
|
static |
Fetch a CentralIdLookup.
string | null | $providerId | Provider ID from $wgCentralIdLookupProviders |
Definition at line 46 of file CentralIdLookup.php.
References $wgCentralIdLookupProvider, and $wgCentralIdLookupProviders.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().
|
static |
Returns a CentralIdLookup that is guaranteed to be non-local.
If no such guarantee can be made, returns null.
If this function returns a non-null CentralIdLookup, that lookup is expected to provide IDs that are shared with some set of other wikis. However, you should still be cautious when using those IDs, as they will not necessarily work with all other wikis, and it can be hard to tell if another wiki is in the same set as this one or not.
Definition at line 82 of file CentralIdLookup.php.
|
final |
Definition at line 108 of file CentralIdLookup.php.
|
abstract |
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.
User | $user | |
string | null | $wikiId | Wiki to check attachment status. If null, check the current wiki. |
Reimplemented in LocalIdLookup.
Referenced by centralIdFromLocalUser().
CentralIdLookup::localUserFromCentralId | ( | $id, | |
$audience = self::AUDIENCE_PUBLIC, | |||
$flags = self::READ_NORMAL ) |
Given a central user ID, return a local User object.
int | $id | Central user ID |
int | User | $audience | One of the audience constants, or a specific user |
int | $flags | IDBAccessObject read flags |
Definition at line 261 of file CentralIdLookup.php.
References $user, nameFromCentralId(), and User\newFromName().
|
abstract |
Given central user IDs, return the (local) user names.
array | $idToName | Array with keys being central user IDs |
int | User | $audience | One of the audience constants, or a specific user |
int | $flags | IDBAccessObject read flags |
Reimplemented in LocalIdLookup.
Referenced by nameFromCentralId(), and namesFromCentralIds().
|
abstract |
Given (local) user names, return the central IDs.
array | $nameToId | Array with keys being canonicalized user names |
int | User | $audience | One of the audience constants, or a specific user |
int | $flags | IDBAccessObject read flags |
Reimplemented in LocalIdLookup.
Referenced by centralIdFromName(), and centralIdsFromNames().
CentralIdLookup::nameFromCentralId | ( | $id, | |
$audience = self::AUDIENCE_PUBLIC, | |||
$flags = self::READ_NORMAL ) |
Given a central user ID, return the (local) user name.
int | $id | Central user ID |
int | User | $audience | One of the audience constants, or a specific user |
int | $flags | IDBAccessObject read flags |
Definition at line 184 of file CentralIdLookup.php.
References lookupCentralIds().
Referenced by localUserFromCentralId().
CentralIdLookup::namesFromCentralIds | ( | array | $ids, |
$audience = self::AUDIENCE_PUBLIC, | |||
$flags = self::READ_NORMAL ) |
Given a an array of central user IDs, return the (local) user names.
int[] | $ids | Central user IDs |
int | User | $audience | One of the audience constants, or a specific user |
int | $flags | IDBAccessObject read flags |
Definition at line 199 of file CentralIdLookup.php.
References lookupCentralIds().
|
static |
Reset internal cache for unit testing.
Definition at line 101 of file CentralIdLookup.php.
|
staticprivate |
Definition at line 36 of file CentralIdLookup.php.
|
private |
Definition at line 39 of file CentralIdLookup.php.
const CentralIdLookup::AUDIENCE_PUBLIC = 1 |
Definition at line 32 of file CentralIdLookup.php.
const CentralIdLookup::AUDIENCE_RAW = 2 |
Definition at line 33 of file CentralIdLookup.php.