MediaWiki  master
MediaWiki\Block\BlockUser Class Reference

Handles the backend logic of blocking users. More...

Collaboration diagram for MediaWiki\Block\BlockUser:

Public Member Functions

 __construct (ServiceOptions $options, BlockRestrictionStore $blockRestrictionStore, BlockPermissionCheckerFactory $blockPermissionCheckerFactory, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo, HookContainer $hookContainer, DatabaseBlockStore $databaseBlockStore, UserFactory $userFactory, UserEditTracker $userEditTracker, LoggerInterface $logger, TitleFactory $titleFactory, $target, Authority $performer, string $expiry, string $reason, array $blockOptions, array $blockRestrictions, array $tags)
 
 placeBlock (bool $reblock=false)
 Places a block with checking permissions. More...
 
 placeBlockUnsafe (bool $reblock=false)
 Places a block without any sort of permissions checks. More...
 
 setLogDeletionFlags (int $flags)
 

Static Public Member Functions

static parseExpiryInput (string $expiry)
 Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute ("24 May 2034", etc), into an absolute timestamp we can put into the database. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Member Functions

 blockLogFlags ()
 Return a comma-delimited list of flags to be passed to the log reader for this block, to provide more information in the logs. More...
 
 configureBlock ( $sourceBlock=null)
 Configure DatabaseBlock according to class properties. More...
 
 constructLogParams ()
 Prepare $logParams. More...
 
 getActionRestrictions ()
 Build an array of actions from $this->blockRestrictions. More...
 
 getNamespaceRestrictions ()
 Build namespace restrictions array from $this->blockRestrictions. More...
 
 getPageRestrictions ()
 Build an array of page restrictions from $this->blockRestrictions. More...
 
 isPartial ()
 Is the to-be-placed block partial? More...
 
 log (DatabaseBlock $block, bool $isReblock)
 Log the block to Special:Log. More...
 
 placeBlockInternal (bool $reblock=true)
 Places a block without any sort of permission or double checking, hooks can still abort the block through, as well as already existing block. More...
 

Private Attributes

BlockActionInfo $blockActionInfo
 
BlockPermissionChecker $blockPermissionChecker
 
AbstractRestriction[] $blockRestrictions = []
 
BlockRestrictionStore $blockRestrictionStore
 
BlockUtils $blockUtils
 
DatabaseBlockStore $databaseBlockStore
 
string bool $expiryTime
 Parsed expiry. More...
 
HookRunner $hookRunner
 
bool $isAutoblocking = true
 
bool $isCreateAccountBlocked = false
 
bool $isEmailBlocked = false
 
bool $isHardBlock = true
 
bool $isHideUser = false
 
bool $isPartialRaw = false
 Flag that needs to be true when the to-be-created block allows all editing, but does not allow some other action. More...
 
bool null $isUserTalkEditBlocked = null
 This may be null when an invalid option was passed to the constructor. More...
 
int null $logDeletionFlags
 
LoggerInterface $logger
 
ServiceOptions $options
 
Authority $performer
 Performer of the block. More...
 
string $rawExpiry
 Expiry of the to-be-placed block exactly as it was passed to the constructor. More...
 
string $reason
 
string[] $tags = []
 
UserIdentity string null $target
 Target of the block. More...
 
int $targetType
 One of AbstractBlock::TYPE_* constants. More...
 
TitleFactory $titleFactory
 
UserEditTracker $userEditTracker
 
UserFactory $userFactory
 

Detailed Description

Handles the backend logic of blocking users.

Since
1.36

Definition at line 52 of file BlockUser.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\BlockUser::__construct ( ServiceOptions  $options,
BlockRestrictionStore  $blockRestrictionStore,
BlockPermissionCheckerFactory  $blockPermissionCheckerFactory,
BlockUtils  $blockUtils,
BlockActionInfo  $blockActionInfo,
HookContainer  $hookContainer,
DatabaseBlockStore  $databaseBlockStore,
UserFactory  $userFactory,
UserEditTracker  $userEditTracker,
LoggerInterface  $logger,
TitleFactory  $titleFactory,
  $target,
Authority  $performer,
string  $expiry,
string  $reason,
array  $blockOptions,
array  $blockRestrictions,
array  $tags 
)
Parameters
ServiceOptions$options
BlockRestrictionStore$blockRestrictionStore
BlockPermissionCheckerFactory$blockPermissionCheckerFactory
BlockUtils$blockUtils
BlockActionInfo$blockActionInfo
HookContainer$hookContainer
DatabaseBlockStore$databaseBlockStore
UserFactory$userFactory
UserEditTracker$userEditTracker
LoggerInterface$logger
TitleFactory$titleFactory
string | UserIdentity$targetTarget of the block
Authority$performerPerformer of the block
string$expiryExpiry of the block (timestamp or 'infinity')
string$reasonReason of the block
bool[]$blockOptionsValid options:
  • isCreateAccountBlocked : Are account creations prevented?
  • isEmailBlocked : Is emailing other users prevented?
  • isHardBlock : Are registered users prevented from editing?
  • isAutoblocking : Should this block spread to others to limit block evasion?
  • isUserTalkEditBlocked : Is editing blocked user's own talkpage allowed?
  • isHideUser : Should blocked user's name be hidden (needs hideuser)?
  • isPartial : Is this block partial? This is ignored when blockRestrictions is not an empty array.
array$blockRestrictions
string[]$tagsTags that should be assigned to the log entry

Definition at line 207 of file BlockUser.php.

References MediaWiki\Block\BlockUser\$blockActionInfo, MediaWiki\Block\BlockUser\$blockRestrictions, MediaWiki\Block\BlockUser\$blockRestrictionStore, MediaWiki\Block\BlockUser\$blockUtils, MediaWiki\Block\BlockUser\$databaseBlockStore, MediaWiki\Block\BlockUser\$logger, MediaWiki\Block\BlockUser\$options, MediaWiki\Block\BlockUser\$performer, MediaWiki\Block\BlockUser\$reason, MediaWiki\Block\BlockUser\$tags, MediaWiki\Block\BlockUser\$target, MediaWiki\Block\BlockUser\$titleFactory, MediaWiki\Block\BlockUser\$userEditTracker, MediaWiki\Block\BlockUser\$userFactory, MediaWiki\Config\ServiceOptions\assertRequiredOptions(), MediaWiki\MainConfigNames\BlockAllowsUTEdit, MediaWiki\Block\BlockUser\getNamespaceRestrictions(), MediaWiki\Block\BlockUser\isPartial(), MediaWiki\Block\BlockPermissionCheckerFactory\newBlockPermissionChecker(), NS_USER_TALK, MediaWiki\Block\BlockUser\parseExpiryInput(), and MediaWiki\Block\Block\TYPE_USER.

Member Function Documentation

◆ blockLogFlags()

MediaWiki\Block\BlockUser::blockLogFlags ( )
private

Return a comma-delimited list of flags to be passed to the log reader for this block, to provide more information in the logs.

Returns
string

Definition at line 730 of file BlockUser.php.

◆ configureBlock()

MediaWiki\Block\BlockUser::configureBlock (   $sourceBlock = null)
private

Configure DatabaseBlock according to class properties.

Parameters
DatabaseBlock | null$sourceBlockCopy any options from this block, null to construct a new one.
Returns
DatabaseBlock

Definition at line 368 of file BlockUser.php.

◆ constructLogParams()

MediaWiki\Block\BlockUser::constructLogParams ( )
private

Prepare $logParams.

Helper method for $this->log()

Returns
array

Definition at line 673 of file BlockUser.php.

◆ getActionRestrictions()

MediaWiki\Block\BlockUser::getActionRestrictions ( )
private

Build an array of actions from $this->blockRestrictions.

Returns an array of stringified actions.

Returns
string[]

Definition at line 656 of file BlockUser.php.

◆ getNamespaceRestrictions()

MediaWiki\Block\BlockUser::getNamespaceRestrictions ( )
private

Build namespace restrictions array from $this->blockRestrictions.

Returns an array of namespace IDs.

Returns
int[]

Definition at line 622 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ getPageRestrictions()

MediaWiki\Block\BlockUser::getPageRestrictions ( )
private

Build an array of page restrictions from $this->blockRestrictions.

Returns an array of stringified full page titles.

Returns
string[]

Definition at line 639 of file BlockUser.php.

◆ isPartial()

MediaWiki\Block\BlockUser::isPartial ( )
private

Is the to-be-placed block partial?

Returns
bool

Definition at line 356 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ log()

MediaWiki\Block\BlockUser::log ( DatabaseBlock  $block,
bool  $isReblock 
)
private

Log the block to Special:Log.

Parameters
DatabaseBlock$block
bool$isReblock

Definition at line 705 of file BlockUser.php.

References MediaWiki\Block\DatabaseBlock\getId(), Title\makeTitle(), and NS_USER.

◆ parseExpiryInput()

static MediaWiki\Block\BlockUser::parseExpiryInput ( string  $expiry)
static

Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute ("24 May 2034", etc), into an absolute timestamp we can put into the database.

Todo:
strtotime() only accepts English strings. This means the expiry input can only be specified in English.
See also
https://www.php.net/manual/en/function.strtotime.php
Parameters
string$expiryWhatever was typed into the form
Returns
string|false Timestamp (format TS_MW) or 'infinity' or false on error.

Definition at line 336 of file BlockUser.php.

References wfIsInfinity(), and wfTimestamp().

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ placeBlock()

MediaWiki\Block\BlockUser::placeBlock ( bool  $reblock = false)

Places a block with checking permissions.

Parameters
bool$reblockShould this reblock?
Returns
Status If the block is successful, the value of the returned Status is an instance of a newly placed block.

Definition at line 414 of file BlockUser.php.

References StatusValue\newFatal().

◆ placeBlockInternal()

MediaWiki\Block\BlockUser::placeBlockInternal ( bool  $reblock = true)
private

Places a block without any sort of permission or double checking, hooks can still abort the block through, as well as already existing block.

Parameters
bool$reblockShould this reblock?
Returns
Status

Definition at line 543 of file BlockUser.php.

References StatusValue\newGood().

◆ placeBlockUnsafe()

MediaWiki\Block\BlockUser::placeBlockUnsafe ( bool  $reblock = false)

Places a block without any sort of permissions checks.

Parameters
bool$reblockShould this reblock?
Returns
Status If the block is successful, the value of the returned Status is an instance of a newly placed block.

Definition at line 477 of file BlockUser.php.

◆ setLogDeletionFlags()

MediaWiki\Block\BlockUser::setLogDeletionFlags ( int  $flags)
Stability: unstable
This method might be removed without prior notice (see T271101)
Parameters
int$flagsOne of LogPage::* constants

Definition at line 320 of file BlockUser.php.

Member Data Documentation

◆ $blockActionInfo

BlockActionInfo MediaWiki\Block\BlockUser::$blockActionInfo
private

Definition at line 106 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $blockPermissionChecker

BlockPermissionChecker MediaWiki\Block\BlockUser::$blockPermissionChecker
private

Definition at line 82 of file BlockUser.php.

◆ $blockRestrictions

AbstractRestriction [] MediaWiki\Block\BlockUser::$blockRestrictions = []
private

Definition at line 169 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $blockRestrictionStore

BlockRestrictionStore MediaWiki\Block\BlockUser::$blockRestrictionStore
private

Definition at line 79 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $blockUtils

BlockUtils MediaWiki\Block\BlockUser::$blockUtils
private

Definition at line 85 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $databaseBlockStore

DatabaseBlockStore MediaWiki\Block\BlockUser::$databaseBlockStore
private

Definition at line 91 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $expiryTime

string bool MediaWiki\Block\BlockUser::$expiryTime
private

Parsed expiry.

This may be false in case of an error in parsing.

Definition at line 128 of file BlockUser.php.

◆ $hookRunner

HookRunner MediaWiki\Block\BlockUser::$hookRunner
private

Definition at line 88 of file BlockUser.php.

◆ $isAutoblocking

bool MediaWiki\Block\BlockUser::$isAutoblocking = true
private

Definition at line 151 of file BlockUser.php.

◆ $isCreateAccountBlocked

bool MediaWiki\Block\BlockUser::$isCreateAccountBlocked = false
private

Definition at line 134 of file BlockUser.php.

◆ $isEmailBlocked

bool MediaWiki\Block\BlockUser::$isEmailBlocked = false
private

Definition at line 145 of file BlockUser.php.

◆ $isHardBlock

bool MediaWiki\Block\BlockUser::$isHardBlock = true
private

Definition at line 148 of file BlockUser.php.

◆ $isHideUser

bool MediaWiki\Block\BlockUser::$isHideUser = false
private

Definition at line 154 of file BlockUser.php.

◆ $isPartialRaw

bool MediaWiki\Block\BlockUser::$isPartialRaw = false
private

Flag that needs to be true when the to-be-created block allows all editing, but does not allow some other action.

This flag is used only by isPartial(), and should not be used anywhere else, even within this class. If you want to determine whether the block will be partial, use $this->isPartial().

Definition at line 166 of file BlockUser.php.

◆ $isUserTalkEditBlocked

bool null MediaWiki\Block\BlockUser::$isUserTalkEditBlocked = null
private

This may be null when an invalid option was passed to the constructor.

Such a case is caught in placeBlockUnsafe.

Definition at line 142 of file BlockUser.php.

◆ $logDeletionFlags

int null MediaWiki\Block\BlockUser::$logDeletionFlags
private

Definition at line 175 of file BlockUser.php.

◆ $logger

LoggerInterface MediaWiki\Block\BlockUser::$logger
private

Definition at line 100 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $options

ServiceOptions MediaWiki\Block\BlockUser::$options
private

Definition at line 76 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $performer

Authority MediaWiki\Block\BlockUser::$performer
private

Performer of the block.

Definition at line 73 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $rawExpiry

string MediaWiki\Block\BlockUser::$rawExpiry
private

Expiry of the to-be-placed block exactly as it was passed to the constructor.

Definition at line 121 of file BlockUser.php.

◆ $reason

string MediaWiki\Block\BlockUser::$reason
private

Definition at line 131 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $tags

string [] MediaWiki\Block\BlockUser::$tags = []
private

Definition at line 172 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $target

UserIdentity string null MediaWiki\Block\BlockUser::$target
private

Target of the block.

This is null in case BlockUtils::parseBlockTarget failed to parse the target. Such case is detected in placeBlockUnsafe, by calling validateTarget from SpecialBlock.

Definition at line 61 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $targetType

int MediaWiki\Block\BlockUser::$targetType
private

One of AbstractBlock::TYPE_* constants.

This will be -1 if BlockUtils::parseBlockTarget failed to parse the target.

Definition at line 70 of file BlockUser.php.

◆ $titleFactory

TitleFactory MediaWiki\Block\BlockUser::$titleFactory
private

Definition at line 103 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $userEditTracker

UserEditTracker MediaWiki\Block\BlockUser::$userEditTracker
private

Definition at line 97 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ $userFactory

UserFactory MediaWiki\Block\BlockUser::$userFactory
private

Definition at line 94 of file BlockUser.php.

Referenced by MediaWiki\Block\BlockUser\__construct().

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Block\BlockUser::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const HideUserContribLimit
Name constant for the HideUserContribLimit setting, for use with Config::get()
const BlockAllowsUTEdit
Name constant for the BlockAllowsUTEdit setting, for use with Config::get()
Access: internal
For use by UserBlockCommandFactory

Definition at line 111 of file BlockUser.php.


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