MediaWiki master
MediaWiki\User\Registration\UserRegistrationLookup Class Reference

Public Member Functions

 __construct (ServiceOptions $options, private readonly ObjectFactory $objectFactory,)
 getFirstRegistration (UserIdentity $user)
 Find the first registration timestamp for a given user.
 getFirstRegistrationBatch (iterable $users)
 Get the first registration timestamp for a batch of users.
 getRegistration (UserIdentity $user, string $type=LocalUserRegistrationProvider::TYPE)
 getRegistrationBatch (iterable $users, string $type=LocalUserRegistrationProvider::TYPE)
 Get the registration timestamp for a batch of users.
 isRegistered (string $type)
 Is a registration provider registered?
 setCachedRegistration (UserIdentity $user, string|null|false $timestamp, string $type=LocalUserRegistrationProvider::TYPE)
 Sets the cached registration timestamp for a given user.

Detailed Description

Since
1.41

Definition at line 17 of file UserRegistrationLookup.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\Registration\UserRegistrationLookup::__construct ( ServiceOptions $options,
private readonly ObjectFactory $objectFactory )

Member Function Documentation

◆ getFirstRegistration()

MediaWiki\User\Registration\UserRegistrationLookup::getFirstRegistration ( UserIdentity $user)

Find the first registration timestamp for a given user.

Note this invokes all registered providers (via cache). Overall result is not cached.

Parameters
UserIdentity$user
Returns
string|null Earliest registration timestamp (TS::MW), null if not available.

Definition at line 147 of file UserRegistrationLookup.php.

References getRegistration().

◆ getFirstRegistrationBatch()

MediaWiki\User\Registration\UserRegistrationLookup::getFirstRegistrationBatch ( iterable $users)

Get the first registration timestamp for a batch of users.

This invokes all registered providers and doesn't use caching.

Parameters
iterable<UserIdentity>$users
Returns
array<int, string|null> Map of registration timestamps in MediaWiki format keyed by user ID. The timestamp may be null for users without a stored registration timestamp and for anonymous users.

Definition at line 175 of file UserRegistrationLookup.php.

◆ getRegistration()

MediaWiki\User\Registration\UserRegistrationLookup::getRegistration ( UserIdentity $user,
string $type = LocalUserRegistrationProvider::TYPE )
Parameters
UserIdentity$userUser for which registration should be fetched.
string$typeName of a registered registration provider
Returns
string|null|false Registration timestamp (TS::MW), null if not available or false if it cannot be fetched (anonymous users, for example).

Definition at line 81 of file UserRegistrationLookup.php.

References if, and MediaWiki\User\Registration\LocalUserRegistrationProvider\TYPE.

Referenced by getFirstRegistration().

◆ getRegistrationBatch()

MediaWiki\User\Registration\UserRegistrationLookup::getRegistrationBatch ( iterable $users,
string $type = LocalUserRegistrationProvider::TYPE )

Get the registration timestamp for a batch of users.

This skips the in-process cache (the batched query takes approx. the same time for any reasonable amount of users; cache would only give us a benefit if all $users were a cache hit, which is extremely unlikely).

Since
1.47
Parameters
iterable<UserIdentity>$users
string$typeName of a registered registration provider
Returns
array<int, string|null> Registration timestamp (TS::MW); null if not available or cannot be fetched (e.g. anonymous users); keyed by user ID.

Definition at line 110 of file UserRegistrationLookup.php.

References return, and MediaWiki\User\Registration\LocalUserRegistrationProvider\TYPE.

◆ isRegistered()

MediaWiki\User\Registration\UserRegistrationLookup::isRegistered ( string $type)

Is a registration provider registered?

See also
MainConfigSchema::UserRegistrationLookupProviders
Parameters
string$type
Returns
bool

Definition at line 52 of file UserRegistrationLookup.php.

References return.

Referenced by setCachedRegistration().

◆ setCachedRegistration()

MediaWiki\User\Registration\UserRegistrationLookup::setCachedRegistration ( UserIdentity $user,
string|null|false $timestamp,
string $type = LocalUserRegistrationProvider::TYPE )

Sets the cached registration timestamp for a given user.

Can only be used to set the date for registered users. If the size of the cache exceeds CACHE_MAX_SIZE, the least recently used entry is evicted.

See also
MapCacheLRU
Access: internal
Only public for usage within the User class and tests

Definition at line 124 of file UserRegistrationLookup.php.

References if, isRegistered(), and MediaWiki\User\Registration\LocalUserRegistrationProvider\TYPE.


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