MediaWiki master
MediaWiki\Block\Block Interface Reference

Represents a block that may prevent users from performing specific operations. More...

Inherits MediaWiki\DAO\WikiAwareEntity.

Inherited by MediaWiki\Block\AbstractBlock.

Collaboration diagram for MediaWiki\Block\Block:

Public Member Functions

 getBlocker ()
 Get the user who applied this block.
 
 getExpiry ()
 Get the block expiry time.
 
 getId ( $wikiId=self::LOCAL)
 Get the block ID.
 
 getIdentifier ( $wikiId=self::LOCAL)
 Get the information that identifies this block, such that a user could look up everything that can be found about this block.
 
 getReasonComment ()
 Get the reason for creating the block.
 
 getTargetName ()
 Return the name of the block target as a string.
 
 getTargetUserIdentity ()
 Get the UserIdentity identifying the blocked user, if the target is indeed a user (that is, if getType() returns TYPE_USER).
 
 getTimestamp ()
 Get the timestamp indicating when the block was created.
 
 getType ()
 Get the type of target for this particular block.
 
 isBlocking ( $target)
 Determine whether this block is blocking the given target (and only that target).
 
 isCreateAccountBlocked ()
 Get the flag indicating whether this block blocks the target from creating an account.
 
 isHardblock ()
 Get whether the block is a hard block (affects logged-in users on a given IP/range).
 
 isSitewide ()
 Get whether the block is a sitewide block.
 
 toArray ()
 Convert a block to an array of blocks.
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 
 getWikiId ()
 Get the ID of the wiki this page belongs to.
 

Public Attributes

const BLOCK_TYPES
 Map block types to strings, to allow convenient logging.
 
const TYPE_AUTO = 4
 
const TYPE_ID = 5
 
const TYPE_IP = 2
 
const TYPE_RANGE = 3
 
const TYPE_USER = 1
 

Detailed Description

Represents a block that may prevent users from performing specific operations.

The block may apply to a specific user, to a network address, network range, or some other aspect of a web request.

The block may apply to the entire site, or may be limited to specific pages or namespaces.

Since
1.37

Extracted from the AbstractBlock base class, which was in turn factored out of DatabaseBlock in 1.34. Block was introduced as a narrow interface for Authority. It avoids legacy types such as User and Title. However, all implementations should continue to extend AbstractBlock.

Extends WikiAwareEntity since 1.38.

Definition at line 45 of file Block.php.

Member Function Documentation

◆ getBlocker()

MediaWiki\Block\Block::getBlocker ( )

Get the user who applied this block.

Returns
UserIdentity|null user identity or null. May be an external user.

Implemented in MediaWiki\Block\CompositeBlock, MediaWiki\Block\DatabaseBlock, and MediaWiki\Block\SystemBlock.

◆ getExpiry()

MediaWiki\Block\Block::getExpiry ( )

Get the block expiry time.

Returns
string

Implemented in MediaWiki\Block\AbstractBlock, and MediaWiki\Block\CompositeBlock.

◆ getId()

MediaWiki\Block\Block::getId ( $wikiId = self::LOCAL)

Get the block ID.

Parameters
string | false$wikiId(since 1.38)
Returns
?int

Implemented in MediaWiki\Block\AbstractBlock, and MediaWiki\Block\DatabaseBlock.

◆ getIdentifier()

MediaWiki\Block\Block::getIdentifier ( $wikiId = self::LOCAL)

Get the information that identifies this block, such that a user could look up everything that can be found about this block.

Typically a scalar ID (integer or string), but can also return a list of IDs, or an associative array encoding a composite ID. Must be safe to serialize as JSON.

Parameters
string | false$wikiId(since 1.38)
Returns
mixed Identifying information

Implemented in MediaWiki\Block\CompositeBlock, MediaWiki\Block\DatabaseBlock, and MediaWiki\Block\SystemBlock.

◆ getReasonComment()

MediaWiki\Block\Block::getReasonComment ( )

Get the reason for creating the block.

Returns
CommentStoreComment

Implemented in MediaWiki\Block\AbstractBlock.

◆ getTargetName()

MediaWiki\Block\Block::getTargetName ( )

Return the name of the block target as a string.

Depending on the type returned by getType(), this could be a user name, an IP address or range, an internal ID, etc.

Returns
string

Implemented in MediaWiki\Block\AbstractBlock.

◆ getTargetUserIdentity()

MediaWiki\Block\Block::getTargetUserIdentity ( )

Get the UserIdentity identifying the blocked user, if the target is indeed a user (that is, if getType() returns TYPE_USER).

Returns
?UserIdentity

Implemented in MediaWiki\Block\AbstractBlock.

◆ getTimestamp()

MediaWiki\Block\Block::getTimestamp ( )

Get the timestamp indicating when the block was created.

Returns
string

Implemented in MediaWiki\Block\AbstractBlock, and MediaWiki\Block\CompositeBlock.

◆ getType()

MediaWiki\Block\Block::getType ( )

Get the type of target for this particular block.

Returns
int|null Block::TYPE_ constant, will never be TYPE_ID

Implemented in MediaWiki\Block\AbstractBlock, and MediaWiki\Block\DatabaseBlock.

◆ isBlocking()

MediaWiki\Block\Block::isBlocking ( $target)

Determine whether this block is blocking the given target (and only that target).

Parameters
UserIdentity | string$target
Returns
bool

Implemented in MediaWiki\Block\AbstractBlock.

◆ isCreateAccountBlocked()

MediaWiki\Block\Block::isCreateAccountBlocked ( )

Get the flag indicating whether this block blocks the target from creating an account.

(Note that the flag may be overridden depending on global configs.)

Returns
bool

Referenced by MediaWiki\Block\DatabaseBlock\__construct(), and MediaWiki\Block\SystemBlock\appliesToPasswordReset().

◆ isHardblock()

MediaWiki\Block\Block::isHardblock ( )

Get whether the block is a hard block (affects logged-in users on a given IP/range).

Note that temporary users are not considered logged-in here - they are always blocked by IP-address blocks.

Note that user blocks are always hard blocks, since the target is logged in by definition.

Returns
bool

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

◆ isSitewide()

MediaWiki\Block\Block::isSitewide ( )

Get whether the block is a sitewide block.

This means the user is prohibited from editing any page on the site (other than their own talk page).

Returns
bool

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

◆ toArray()

MediaWiki\Block\Block::toArray ( )

Convert a block to an array of blocks.

If the block is a composite block, return the array of original blocks. Otherwise, return [$this].

Since
1.41
Returns
Block[]

Implemented in MediaWiki\Block\AbstractBlock, and MediaWiki\Block\CompositeBlock.

Member Data Documentation

◆ BLOCK_TYPES

const MediaWiki\Block\Block::BLOCK_TYPES
Initial value:
= [
self::TYPE_USER => 'user',
self::TYPE_IP => 'ip',
self::TYPE_RANGE => 'range',
self::TYPE_AUTO => 'autoblock',
self::TYPE_ID => 'id',
]

Map block types to strings, to allow convenient logging.

Definition at line 58 of file Block.php.

◆ TYPE_AUTO

◆ TYPE_ID

const MediaWiki\Block\Block::TYPE_ID = 5

Definition at line 53 of file Block.php.

Referenced by MediaWiki\Block\DatabaseBlockStore\newListFromTarget().

◆ TYPE_IP

◆ TYPE_RANGE

◆ TYPE_USER


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