MediaWiki  master
MediaWiki\User\TempUser\TempUserCreator Class Reference

Service for temporary user creation. More...

Inheritance diagram for MediaWiki\User\TempUser\TempUserCreator:
Collaboration diagram for MediaWiki\User\TempUser\TempUserCreator:

Public Member Functions

 __construct (RealTempUserConfig $config, ObjectFactory $objectFactory, UserFactory $userFactory, AuthManager $authManager, ?Throttler $throttler)
 
 acquireAndStashName (Session $session)
 Permanently acquire a username, stash it in a session, and return it. More...
 
 create ( $name=null, WebRequest $request=null)
 Acquire a serial number, create the corresponding user and log in. More...
 
 getPlaceholderName ()
 Get a placeholder name which matches the reserved prefix. More...
 
 isAutoCreateAction (string $action)
 Is the action valid for user auto-creation? More...
 
 isEnabled ()
 Is temp user creation enabled? More...
 
 isReservedName (string $name)
 Does the name match the configured pattern indicating that it is a temporary auto-created user? More...
 

Private Member Functions

 acquireName ()
 Acquire a new username and return it. More...
 
 createSerialMapping ()
 Create the serial map. More...
 
 createSerialProvider ()
 Create the serial provider. More...
 
 getSerialMapping ()
 Get the serial mapping. More...
 
 getSerialProvider ()
 Get the serial provider. More...
 

Private Attributes

AuthManager $authManager
 
RealTempUserConfig $config
 
ObjectFactory $objectFactory
 
SerialMapping null $serialMapping
 
array $serialMappingConfig
 
SerialProvider null $serialProvider
 
array $serialProviderConfig
 
Throttler null $throttler
 
UserFactory $userFactory
 
const SERIAL_MAPPINGS
 ObjectFactory specs for the core serial maps. More...
 
const SERIAL_PROVIDERS
 ObjectFactory specs for the core serial providers. More...
 

Detailed Description

Service for temporary user creation.

For convenience this also proxies the TempUserConfig methods.

This is separate from TempUserConfig to avoid dependency loops. Special pages and actions are free to use this class, but services should take it as a constructor parameter only if necessary.

Since
1.39

Definition at line 25 of file TempUserCreator.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ acquireAndStashName()

MediaWiki\User\TempUser\TempUserCreator::acquireAndStashName ( Session  $session)

Permanently acquire a username, stash it in a session, and return it.

Do not create the user.

If this method was called before with the same session ID, return the previously stashed username instead of acquiring a new one.

Parameters
Session$session
Returns
string The username

Definition at line 262 of file TempUserCreator.php.

References MediaWiki\Session\Session\get(), MediaWiki\Session\Session\save(), and MediaWiki\Session\Session\set().

◆ acquireName()

MediaWiki\User\TempUser\TempUserCreator::acquireName ( )
private

Acquire a new username and return it.

Permanently reserve the ID in the database.

Returns
string

Definition at line 167 of file TempUserCreator.php.

◆ create()

MediaWiki\User\TempUser\TempUserCreator::create (   $name = null,
WebRequest  $request = null 
)

Acquire a serial number, create the corresponding user and log in.

Parameters
string | null$namePreviously acquired name
WebRequest | null$requestRequest details, used for throttling
Returns
CreateStatus

Definition at line 101 of file TempUserCreator.php.

References wfMessage().

◆ createSerialMapping()

MediaWiki\User\TempUser\TempUserCreator::createSerialMapping ( )
private

Create the serial map.

Returns
SerialMapping

Definition at line 228 of file TempUserCreator.php.

References $type.

◆ createSerialProvider()

MediaWiki\User\TempUser\TempUserCreator::createSerialProvider ( )
private

Create the serial provider.

Returns
SerialProvider

Definition at line 188 of file TempUserCreator.php.

References $type.

◆ getPlaceholderName()

MediaWiki\User\TempUser\TempUserCreator::getPlaceholderName ( )

Get a placeholder name which matches the reserved prefix.

Returns
string

Implements MediaWiki\User\TempUser\TempUserConfig.

Definition at line 157 of file TempUserCreator.php.

◆ getSerialMapping()

MediaWiki\User\TempUser\TempUserCreator::getSerialMapping ( )
private

Get the serial mapping.

Returns
SerialMapping

Definition at line 217 of file TempUserCreator.php.

◆ getSerialProvider()

MediaWiki\User\TempUser\TempUserCreator::getSerialProvider ( )
private

Get the serial provider.

Returns
SerialProvider

Definition at line 177 of file TempUserCreator.php.

◆ isAutoCreateAction()

MediaWiki\User\TempUser\TempUserCreator::isAutoCreateAction ( string  $action)

Is the action valid for user auto-creation?

Parameters
string$action
Returns
bool

Implements MediaWiki\User\TempUser\TempUserConfig.

Definition at line 149 of file TempUserCreator.php.

References MediaWiki\$action.

◆ isEnabled()

MediaWiki\User\TempUser\TempUserCreator::isEnabled ( )

Is temp user creation enabled?

Returns
bool

Implements MediaWiki\User\TempUser\TempUserConfig.

Definition at line 145 of file TempUserCreator.php.

◆ isReservedName()

MediaWiki\User\TempUser\TempUserCreator::isReservedName ( string  $name)

Does the name match the configured pattern indicating that it is a temporary auto-created user?

Parameters
string$name
Returns
bool

Implements MediaWiki\User\TempUser\TempUserConfig.

Definition at line 153 of file TempUserCreator.php.

Member Data Documentation

◆ $authManager

AuthManager MediaWiki\User\TempUser\TempUserCreator::$authManager
private

◆ $config

RealTempUserConfig MediaWiki\User\TempUser\TempUserCreator::$config
private

◆ $objectFactory

ObjectFactory MediaWiki\User\TempUser\TempUserCreator::$objectFactory
private

◆ $serialMapping

SerialMapping null MediaWiki\User\TempUser\TempUserCreator::$serialMapping
private

Definition at line 51 of file TempUserCreator.php.

◆ $serialMappingConfig

array MediaWiki\User\TempUser\TempUserCreator::$serialMappingConfig
private

Definition at line 42 of file TempUserCreator.php.

◆ $serialProvider

SerialProvider null MediaWiki\User\TempUser\TempUserCreator::$serialProvider
private

Definition at line 48 of file TempUserCreator.php.

◆ $serialProviderConfig

array MediaWiki\User\TempUser\TempUserCreator::$serialProviderConfig
private

Definition at line 39 of file TempUserCreator.php.

◆ $throttler

Throttler null MediaWiki\User\TempUser\TempUserCreator::$throttler
private

◆ $userFactory

UserFactory MediaWiki\User\TempUser\TempUserCreator::$userFactory
private

◆ SERIAL_MAPPINGS

const MediaWiki\User\TempUser\TempUserCreator::SERIAL_MAPPINGS
private
Initial value:
= [
'plain-numeric' => [
'class' => PlainNumericSerialMapping::class,
],
'localized-numeric' => [
'class' => LocalizedNumericSerialMapping::class,
'services' => [ 'LanguageFactory' ],
],
'filtered-radix' => [
'class' => FilteredRadixSerialMapping::class,
],
'scramble' => [
'class' => ScrambleMapping::class,
]
]

ObjectFactory specs for the core serial maps.

Definition at line 62 of file TempUserCreator.php.

◆ SERIAL_PROVIDERS

const MediaWiki\User\TempUser\TempUserCreator::SERIAL_PROVIDERS
private
Initial value:
= [
'local' => [
'class' => LocalSerialProvider::class,
'services' => [ 'DBLoadBalancer' ],
]
]

ObjectFactory specs for the core serial providers.

Definition at line 54 of file TempUserCreator.php.


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