MediaWiki REL1_40
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)
 Determines 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 ()
 Returns whether the block is a hardblock (affects logged-in users on a given IP/range)
 
 isSitewide ()
 Indicates that the block is a sitewide block.
 
- 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.

Extends WikiAwareEntity since 1.38.

Definition at line 40 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 get Type(), 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.

◆ 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.

Referenced by ApiBase\dieBlocked().

◆ isBlocking()

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

Determines 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\CompositeBlock\__construct(), MediaWiki\Block\DatabaseBlock\__construct(), MediaWiki\Block\SystemBlock\appliesToPasswordReset(), MediaWiki\Block\DatabaseBlock\doAutoblock(), and MediaWiki\Block\DatabaseBlock\initFromRow().

◆ isHardblock()

MediaWiki\Block\Block::isHardblock ( )

Returns whether the block is a hardblock (affects logged-in users on a given IP/range)

Note that users are always hardblocked, since they're logged in by definition.

Returns
bool

Referenced by MediaWiki\Block\AbstractBlock\__construct(), MediaWiki\Block\CompositeBlock\__construct(), and MediaWiki\Block\DatabaseBlock\initFromRow().

◆ isSitewide()

MediaWiki\Block\Block::isSitewide ( )

Indicates that 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\CompositeBlock\__construct(), MediaWiki\Block\DatabaseBlock\__construct(), ApiBase\dieBlocked(), MediaWiki\Block\DatabaseBlock\doAutoblock(), and MediaWiki\Block\DatabaseBlock\initFromRow().

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 53 of file Block.php.

◆ TYPE_AUTO

const MediaWiki\Block\Block::TYPE_AUTO = 4

Definition at line 47 of file Block.php.

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

◆ TYPE_ID

const MediaWiki\Block\Block::TYPE_ID = 5

Definition at line 48 of file Block.php.

◆ TYPE_IP

◆ TYPE_RANGE

const MediaWiki\Block\Block::TYPE_RANGE = 3

◆ TYPE_USER


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