MediaWiki master
MediaWiki\Block\CompositeBlock Class Reference

Multiple Block class. More...

Inherits MediaWiki\Block\AbstractBlock.

Collaboration diagram for MediaWiki\Block\CompositeBlock:

Public Member Functions

 __construct (array $options=[])
 Create a new block with specified parameters on a user, IP or IP range.
 
 appliesToNamespace ( $ns)
 Checks if a block applies to a particular namespace.
Since
1.33
Parameters
int$ns
Returns
bool

 
 appliesToPage ( $pageId)
 Checks if a block applies to a particular page.This check does not consider whether $this->isUsertalkEditAllowed returns false, as the identity of the user making the hypothetical edit isn't known here (particularly in the case of IP hard blocks, range blocks, and auto-blocks).
Since
1.33
Parameters
int$pageId
Returns
bool

 
 appliesToPasswordReset ()
 Check if the block prevents a user from resetting their password.
Since
1.33
Returns
bool The block blocks password reset

 
 appliesToRight ( $right)
 Determine whether the block prevents a given right.A right may be allowed or disallowed by default, or determined from a property on the block object. For certain rights, the property may be overridden according to global configs.
Since
1.33
Parameters
string$right
Returns
bool|null The block applies to the right, or null if unsure (e.g. unrecognized right or unset property)

 
 appliesToTitle (Title $title)
 Checks if a block applies to a particular title.This check does not consider whether $this->isUsertalkEditAllowed returns false, as the identity of the user making the hypothetical edit isn't known here (particularly in the case of IP hard blocks, range blocks, and auto-blocks).
Parameters
Title$title
Returns
bool

 
 appliesToUsertalk (Title $usertalk=null)
 Determine whether the block allows the user to edit their own user talk page.This is done separately from AbstractBlock::appliesToRight because there is no right for editing one's own user talk page and because the user's talk page needs to be passed into the block object, which is unaware of the user.The bl_allow_usertalk flag (which corresponds to the property allowUsertalk) is used on sitewide blocks and partial blocks that contain a namespace restriction on the user talk namespace, but do not contain a page restriction on the user's talk page. For all other (i.e. most) partial blocks, the flag is ignored, and the user can always edit their user talk page unless there is a page restriction on their user talk page, in which case they can never edit it. (Ideally the flag would be stored as null in these cases, but the database field isn't nullable.)This method does not validate that the passed in talk page belongs to the block target since the target (an IP) might not be the same as the user's talk page (if they are logged in).
Since
1.33
Parameters
Title | null$usertalkThe user's user talk page. If null, and if the target is a User, the target's userpage is used
Returns
bool The user can edit their talk page

 
 getBlocker ()
 Get the user who applied this block.
Returns
UserIdentity|null user identity or null. May be an external user.

 
 getBy ( $wikiId=self::LOCAL)
 Get the user id of the blocking sysop.
Parameters
string | false$wikiId(since 1.38)
Returns
int (0 for foreign users)

 
 getByName ()
 Get the username of the blocking sysop.
Returns
string

 
 getExpiry ()
 Get the block expiry time.
Since
1.19
Returns
string

 
 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

 
 getOriginalBlocks ()
 Get the original blocks from which this block is composed.
 
 getTimestamp ()
 Get the timestamp indicating when the block was created.
Since
1.33
Returns
string

 
 toArray ()
 
 withOriginalBlocks (array $blocks)
 Create a clone of the object with the original blocks array set to something else.
 
- Public Member Functions inherited from MediaWiki\Block\AbstractBlock
 getHideName ()
 Get whether the block hides the target's username.
 
 getId ( $wikiId=self::LOCAL)
 Get the block ID.
Parameters
string | false$wikiId(since 1.38)
Returns
?int

 
 getPermissionsError (IContextSource $context)
 Get the key and parameters for the corresponding error message.
 
 getReasonComment ()
 Get the reason for creating the block.
 
 getTargetName ()
 
 getTargetUserIdentity ()
 
 getType ()
 Get the type of target for this particular block.
 
 getWikiId ()
 
 isBlocking ( $target)
 
 isCreateAccountBlocked ( $x=null)
 Get or set the flag indicating whether this block blocks the target from creating an account.
 
 isEmailBlocked ( $x=null)
 Get or set the flag indicating whether this block blocks the target from sending emails.
 
 isHardblock ( $x=null)
 Get/set whether the block is a hard block (affects logged-in users on a given IP/range).
 
 isSitewide ( $x=null)
 Indicates that the block is a sitewide block.
 
 isUsertalkEditAllowed ( $x=null)
 Get or set the flag indicating whether this block blocks the target from editing their own user talk page.
 
 setExpiry ( $expiry)
 Set the block expiry time.
 
 setHideName ( $hideName)
 Set whether the block hides the target's username.
 
 setReason ( $reason)
 Set the reason for creating the block.
 
 setTarget ( $target)
 Set the target for this block, and update $this->type accordingly.
 
 setTimestamp ( $timestamp)
 Set the timestamp indicating when the block was created.
 
- Public Member Functions inherited from MediaWiki\Block\Block
 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.
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 

Static Public Member Functions

static createFromBlocks (AbstractBlock ... $blocks)
 Helper method for merging multiple blocks into a composite block.
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\Block\Block
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
 
- Protected Attributes inherited from MediaWiki\Block\AbstractBlock
bool $allowUsertalk = false
 
bool $blockCreateAccount = false
 
bool $blockEmail = false
 
string $expiry = ''
 
bool $hideName = false
 
bool $isHardblock
 
bool $isSitewide = true
 
CommentStoreComment $reason
 
UserIdentity string null $target
 
string $timestamp = ''
 
int null $type
 AbstractBlock::TYPE_ constant.
 
string false $wikiId
 

Detailed Description

Multiple Block class.

Multiple blocks exist to enforce restrictions from more than one block, if several blocks apply to a user/IP. Multiple blocks are created temporarily on enforcement.

Since
1.34

Definition at line 38 of file CompositeBlock.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\CompositeBlock::__construct ( array $options = [])

Create a new block with specified parameters on a user, IP or IP range.

Parameters
array$optionsParameters of the block, with options supported by AbstractBlock::__construct, and also:
  • originalBlocks: (Block[]) Blocks that this block is composed from

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 73 of file CompositeBlock.php.

Member Function Documentation

◆ appliesToNamespace()

MediaWiki\Block\CompositeBlock::appliesToNamespace ( $ns)

Checks if a block applies to a particular namespace.

Since
1.33
Parameters
int$ns
Returns
bool

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 237 of file CompositeBlock.php.

◆ appliesToPage()

MediaWiki\Block\CompositeBlock::appliesToPage ( $pageId)

Checks if a block applies to a particular page.This check does not consider whether $this->isUsertalkEditAllowed returns false, as the identity of the user making the hypothetical edit isn't known here (particularly in the case of IP hard blocks, range blocks, and auto-blocks).

Since
1.33
Parameters
int$pageId
Returns
bool

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 244 of file CompositeBlock.php.

◆ appliesToPasswordReset()

MediaWiki\Block\CompositeBlock::appliesToPasswordReset ( )

Check if the block prevents a user from resetting their password.

Since
1.33
Returns
bool The block blocks password reset

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 251 of file CompositeBlock.php.

◆ appliesToRight()

MediaWiki\Block\CompositeBlock::appliesToRight ( $right)

Determine whether the block prevents a given right.A right may be allowed or disallowed by default, or determined from a property on the block object. For certain rights, the property may be overridden according to global configs.

Since
1.33
Parameters
string$right
Returns
bool|null The block applies to the right, or null if unsure (e.g. unrecognized right or unset property)

Determines whether the CompositeBlock applies to a right by checking whether the original blocks apply to that right. Each block can report true (applies), false (does not apply) or null (unsure). Then:

  • If any original blocks apply, this block applies
  • If no original blocks apply but any are unsure, this block is unsure
  • If all blocks do not apply, this block does not apply

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 204 of file CompositeBlock.php.

◆ appliesToTitle()

MediaWiki\Block\CompositeBlock::appliesToTitle ( Title $title)

Checks if a block applies to a particular title.This check does not consider whether $this->isUsertalkEditAllowed returns false, as the identity of the user making the hypothetical edit isn't known here (particularly in the case of IP hard blocks, range blocks, and auto-blocks).

Parameters
Title$title
Returns
bool

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 230 of file CompositeBlock.php.

◆ appliesToUsertalk()

MediaWiki\Block\CompositeBlock::appliesToUsertalk ( Title $usertalk = null)

Determine whether the block allows the user to edit their own user talk page.This is done separately from AbstractBlock::appliesToRight because there is no right for editing one's own user talk page and because the user's talk page needs to be passed into the block object, which is unaware of the user.The bl_allow_usertalk flag (which corresponds to the property allowUsertalk) is used on sitewide blocks and partial blocks that contain a namespace restriction on the user talk namespace, but do not contain a page restriction on the user's talk page. For all other (i.e. most) partial blocks, the flag is ignored, and the user can always edit their user talk page unless there is a page restriction on their user talk page, in which case they can never edit it. (Ideally the flag would be stored as null in these cases, but the database field isn't nullable.)This method does not validate that the passed in talk page belongs to the block target since the target (an IP) might not be the same as the user's talk page (if they are logged in).

Since
1.33
Parameters
Title | null$usertalkThe user's user talk page. If null, and if the target is a User, the target's userpage is used
Returns
bool The user can edit their talk page

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 223 of file CompositeBlock.php.

◆ createFromBlocks()

static MediaWiki\Block\CompositeBlock::createFromBlocks ( AbstractBlock ... $blocks)
static

Helper method for merging multiple blocks into a composite block.

Parameters
AbstractBlock...$blocks
Returns
self

Definition at line 47 of file CompositeBlock.php.

◆ getBlocker()

MediaWiki\Block\CompositeBlock::getBlocker ( )

Get the user who applied this block.

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

Implements MediaWiki\Block\Block.

Definition at line 273 of file CompositeBlock.php.

◆ getBy()

MediaWiki\Block\CompositeBlock::getBy ( $wikiId = self::LOCAL)

Get the user id of the blocking sysop.

Parameters
string | false$wikiId(since 1.38)
Returns
int (0 for foreign users)

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 258 of file CompositeBlock.php.

◆ getByName()

MediaWiki\Block\CompositeBlock::getByName ( )

Get the username of the blocking sysop.

Returns
string

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 266 of file CompositeBlock.php.

◆ getExpiry()

MediaWiki\Block\CompositeBlock::getExpiry ( )

Get the block expiry time.

Since
1.19
Returns
string

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 172 of file CompositeBlock.php.

◆ getIdentifier()

MediaWiki\Block\CompositeBlock::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

Implements MediaWiki\Block\Block.

Definition at line 186 of file CompositeBlock.php.

◆ getOriginalBlocks()

MediaWiki\Block\CompositeBlock::getOriginalBlocks ( )

Get the original blocks from which this block is composed.

Since
1.34
Returns
AbstractBlock[]

Definition at line 133 of file CompositeBlock.php.

◆ getTimestamp()

MediaWiki\Block\CompositeBlock::getTimestamp ( )

Get the timestamp indicating when the block was created.

Since
1.33
Returns
string

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 158 of file CompositeBlock.php.

◆ toArray()

MediaWiki\Block\CompositeBlock::toArray ( )
Returns
AbstractBlock[]

Reimplemented from MediaWiki\Block\AbstractBlock.

Definition at line 151 of file CompositeBlock.php.

◆ withOriginalBlocks()

MediaWiki\Block\CompositeBlock::withOriginalBlocks ( array $blocks)

Create a clone of the object with the original blocks array set to something else.

Since
1.42
Parameters
AbstractBlock[]$blocks
Returns
self

Definition at line 145 of file CompositeBlock.php.


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