MediaWiki master
|
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may be tracked with cookies. More...
Inherits MediaWiki\Block\AbstractBlock.
Public Member Functions | ||||
__construct (array $options=[]) | ||||
Create a new block with specified option parameters on a user, IP or IP range. | ||||
appliesToNamespace ( $ns) | ||||
Checks if a block applies to a particular namespace.
| ||||
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).
| ||||
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.
| ||||
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).
| ||||
delete () | ||||
Delete the row from the IP blocks table. | ||||
doAutoblock ( $autoblockIP) | ||||
Autoblocks the given IP, referring to this block. | ||||
equals (DatabaseBlock $block) | ||||
Check if two blocks are effectively equal. | ||||
getBlocker () | ||||
Get the user who implemented this block. | ||||
getBy ( $wikiId=self::LOCAL) | ||||
Get the user id of the blocking sysop.
| ||||
getByName () | ||||
Get the username of the blocking sysop.
| ||||
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.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.
| ||||
getParentBlockId () | ||||
getRangeEnd () | ||||
Get the IP address at the end of the range in Hex form. | ||||
getRangeStart () | ||||
Get the IP address at the start of the range in Hex form. | ||||
getRawRestrictions () | ||||
Get restrictions without loading from database if not yet loaded. | ||||
getRedactedName () | ||||
Get the block name, but with autoblocked IPs hidden as per standard privacy policy. | ||||
getRestrictions () | ||||
Getting the restrictions will perform a database query if the restrictions are not already loaded. | ||||
getType () | ||||
Get the type of target for this particular block.
| ||||
insert () | ||||
Insert a block into the block table. | ||||
isAutoblocking ( $x=null) | ||||
Does the block cause autoblocks to be created? | ||||
isExpired () | ||||
Has the block expired? | ||||
isHardblock ( $x=null) | ||||
Get/set whether the block is a hard block (affects logged-in users on a given IP/range) | ||||
setBlocker ( $user) | ||||
Set the user who implemented (or will implement) this block. | ||||
setId ( $blockId) | ||||
Set the block ID. | ||||
setRestrictions (array $restrictions) | ||||
update () | ||||
Update a block in the DB with new parameters. | ||||
updateTimestamp () | ||||
Update the timestamp on autoblocks. | ||||
Public Member Functions inherited from MediaWiki\Block\AbstractBlock | ||||
appliesToPasswordReset () | ||||
Check if the block prevents a user from resetting their password. | ||||
appliesToUsertalk (Title $usertalk=null) | ||||
Determine whether the block allows the user to edit their own user talk page. | ||||
getExpiry () | ||||
Get the block expiry time. | ||||
getHideName () | ||||
Get whether the block hides the target's username. | ||||
getReasonComment () | ||||
Get the reason for creating the block. | ||||
getTargetName () | ||||
getTargetUserIdentity () | ||||
getTimestamp () | ||||
Get the timestamp indicating when the block was created. | ||||
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. | ||||
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. | ||||
toArray () | ||||
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 | getAutoblockExpiry ( $timestamp) |
Get the expiry timestamp for an autoblock created at the given time. | |
static | getBlocksForIPList (array $ipChain, $applySoftBlocks, $fromPrimary=false) |
Get all blocks that match any IP from an array of IP addresses. | |
static | getQueryInfo () |
Return the tables, fields, and join conditions to be selected to create a new block object. | |
static | getRangeCond ( $start, $end=null) |
Get a set of SQL conditions which will select range blocks encompassing a given range. | |
static | isExemptedFromAutoblocks ( $ip) |
Checks whether a given IP is on the autoblock exemption list. | |
static | newFromID ( $id) |
Load a block from the block ID. | |
static | newFromRow ( $row) |
Create a new DatabaseBlock object from a database row. | |
static | newFromTarget ( $specificTarget, $vagueTarget=null, $fromPrimary=false) |
Given a target and the target's type, get an existing block object if possible. | |
static | newListFromTarget ( $specificTarget, $vagueTarget=null, $fromPrimary=false) |
This is similar to DatabaseBlock::newFromTarget, but it returns all the relevant blocks. | |
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 |
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may be tracked with cookies.
Such blocks* are more customizable than system blocks: they may be hard blocks, and they may be sitewide or partial.
Definition at line 48 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::__construct | ( | array | $options = [] | ) |
Create a new block with specified option parameters on a user, IP or IP range.
array | $options | Parameters of the block, with options supported by AbstractBlock::__construct , and also:
|
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 87 of file DatabaseBlock.php.
References DB_REPLICA, MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\Block\isCreateAccountBlocked(), MediaWiki\Block\AbstractBlock\isEmailBlocked(), MediaWiki\Block\Block\isSitewide(), MediaWiki\Block\AbstractBlock\isUsertalkEditAllowed(), MediaWiki\Block\DatabaseBlock\setBlocker(), MediaWiki\Block\AbstractBlock\setExpiry(), and MediaWiki\Block\DatabaseBlock\setRestrictions().
MediaWiki\Block\DatabaseBlock::appliesToNamespace | ( | $ns | ) |
Checks if a block applies to a particular namespace.
int | $ns |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 600 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::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).
int | $pageId |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 618 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::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.
string | $right |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 636 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::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).
Title | $title |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 582 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::delete | ( | ) |
Delete the row from the IP blocks table.
Definition at line 232 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Block\AbstractBlock\getWikiId().
MediaWiki\Block\DatabaseBlock::doAutoblock | ( | $autoblockIP | ) |
Autoblocks the given IP, referring to this block.
string | $autoblockIP | The IP to autoblock. |
Definition at line 292 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Block\AbstractBlock\getWikiId().
MediaWiki\Block\DatabaseBlock::equals | ( | DatabaseBlock | $block | ) |
Check if two blocks are effectively equal.
Doesn't check irrelevant things like the blocking user or the block timestamp, only things which affect the blocked user
DatabaseBlock | $block |
Definition at line 178 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\getExpiry(), MediaWiki\Block\AbstractBlock\getHideName(), MediaWiki\Block\AbstractBlock\getReasonComment(), MediaWiki\Block\DatabaseBlock\getRestrictions(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\AbstractBlock\isCreateAccountBlocked(), MediaWiki\Block\AbstractBlock\isEmailBlocked(), MediaWiki\Block\DatabaseBlock\isHardblock(), MediaWiki\Block\AbstractBlock\isSitewide(), and MediaWiki\Block\AbstractBlock\isUsertalkEditAllowed().
|
static |
Get the expiry timestamp for an autoblock created at the given time.
string | int | $timestamp |
Definition at line 450 of file DatabaseBlock.php.
References wfDeprecated().
MediaWiki\Block\DatabaseBlock::getBlocker | ( | ) |
Get the user who implemented this block.
Implements MediaWiki\Block\Block.
Definition at line 716 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlockStore\doAutoblock(), and MediaWiki\Block\DatabaseBlockStore\insertBlock().
|
static |
Get all blocks that match any IP from an array of IP addresses.
array | $ipChain | List of IPs (strings), usually retrieved from the X-Forwarded-For header of the request |
bool | $applySoftBlocks | Include soft blocks (anonymous-only blocks). These should only block anonymous and temporary users. |
bool | $fromPrimary | Whether to query the primary or replica DB |
Definition at line 515 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::getBy | ( | $wikiId = self::LOCAL | ) |
Get the user id of the blocking sysop.
string | false | $wikiId | (since 1.38) |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 699 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::getByName | ( | ) |
Get the username of the blocking sysop.
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 707 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::getId | ( | $wikiId = self::LOCAL | ) |
Get the block ID.
string | false | $wikiId | (since 1.38) |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 361 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlockStore\doAutoblock(), MediaWiki\Block\DatabaseBlockStore\insertBlock(), MediaWiki\Block\DatabaseBlockStore\updateBlock(), MediaWiki\Block\DatabaseBlockStore\updateTarget(), and MediaWiki\Block\DatabaseBlockStore\updateTimestamp().
MediaWiki\Block\DatabaseBlock::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.
string | false | $wikiId | (since 1.38) |
Implements MediaWiki\Block\Block.
Definition at line 535 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::getParentBlockId | ( | ) |
Definition at line 389 of file DatabaseBlock.php.
|
static |
Return the tables, fields, and join conditions to be selected to create a new block object.
Since 1.34, ipb_by and ipb_by_text have not been present in the database, but they continue to be available in query results as aliases.
$table
to IDatabase->select()
or SelectQueryBuilder::tables
$vars
to IDatabase->select()
or SelectQueryBuilder::fields
$join_conds
to IDatabase->select()
or SelectQueryBuilder::joinConds
Definition at line 165 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Block\DatabaseBlockStore\SCHEMA_IPBLOCKS, and wfDeprecated().
|
static |
Get a set of SQL conditions which will select range blocks encompassing a given range.
string | $start | Hexadecimal IP representation |
string | null | $end | Hexadecimal IP representation, or null to use $start = $end |
Definition at line 209 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Block\DatabaseBlockStore\SCHEMA_IPBLOCKS, and wfDeprecated().
MediaWiki\Block\DatabaseBlock::getRangeEnd | ( | ) |
Get the IP address at the end of the range in Hex form.
Definition at line 344 of file DatabaseBlock.php.
References MediaWiki\Block\Block\TYPE_IP, MediaWiki\Block\Block\TYPE_RANGE, and MediaWiki\Block\Block\TYPE_USER.
MediaWiki\Block\DatabaseBlock::getRangeStart | ( | ) |
Get the IP address at the start of the range in Hex form.
Definition at line 326 of file DatabaseBlock.php.
References MediaWiki\Block\Block\TYPE_IP, MediaWiki\Block\Block\TYPE_RANGE, and MediaWiki\Block\Block\TYPE_USER.
MediaWiki\Block\DatabaseBlock::getRawRestrictions | ( | ) |
Get restrictions without loading from database if not yet loaded.
Definition at line 565 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlockStore\updateBlock().
MediaWiki\Block\DatabaseBlock::getRedactedName | ( | ) |
Get the block name, but with autoblocked IPs hidden as per standard privacy policy.
Definition at line 430 of file DatabaseBlock.php.
References wfMessage().
MediaWiki\Block\DatabaseBlock::getRestrictions | ( | ) |
Getting the restrictions will perform a database query if the restrictions are not already loaded.
Definition at line 546 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlockStore\doAutoblock(), and MediaWiki\Block\DatabaseBlock\equals().
MediaWiki\Block\DatabaseBlock::getType | ( | ) |
Get the type of target for this particular block.
Autoblocks have whichever type corresponds to their target, so to detect if a block is an autoblock, we have to check the mAuto property instead.
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 526 of file DatabaseBlock.php.
Referenced by MediaWiki\Specials\SpecialBlock\maybeAlterFormDefaults(), and MediaWiki\Block\DatabaseBlockStore\updateTimestamp().
MediaWiki\Block\DatabaseBlock::insert | ( | ) |
Insert a block into the block table.
Will fail if there is a conflicting block (same name and options) already in the database.
Definition at line 249 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Block\AbstractBlock\getWikiId().
MediaWiki\Block\DatabaseBlock::isAutoblocking | ( | $x = null | ) |
Does the block cause autoblocks to be created?
null | bool | $x |
Definition at line 416 of file DatabaseBlock.php.
References wfSetVar().
Referenced by MediaWiki\Block\DatabaseBlock\__construct(), MediaWiki\Block\DatabaseBlockStore\doAutoblock(), MediaWiki\Block\DatabaseBlock\equals(), and MediaWiki\Block\DatabaseBlockStore\updateBlock().
|
static |
Checks whether a given IP is on the autoblock exemption list.
string | $ip | The IP to check |
Definition at line 279 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance().
MediaWiki\Block\DatabaseBlock::isExpired | ( | ) |
Has the block expired?
Definition at line 303 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\$timestamp, MediaWiki\Block\AbstractBlock\getExpiry(), wfDebug(), and wfTimestampNow().
MediaWiki\Block\DatabaseBlock::isHardblock | ( | $x = null | ) |
Get/set whether the block is a hard block (affects logged-in users on a given IP/range)
bool | null | $x |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 401 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlock\equals().
|
static |
Load a block from the block ID.
int | $id | ID to search for |
Definition at line 139 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance(), and wfDeprecated().
|
static |
Create a new DatabaseBlock object from a database row.
stdClass | $row | Row from the ipblocks table |
Definition at line 220 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance().
|
static |
Given a target and the target's type, get an existing block object if possible.
string | UserIdentity | int | null | $specificTarget | A block target, which may be one of several types:
|
string | UserIdentity | int | null | $vagueTarget | As above, but we will search for any block which affects that target (so for an IP address, get ranges containing that IP; and also get any relevant autoblocks). Leave empty or blank to skip IP-based lookups. |
bool | $fromPrimary | Whether to use the DB_PRIMARY database |
Definition at line 477 of file DatabaseBlock.php.
|
static |
This is similar to DatabaseBlock::newFromTarget, but it returns all the relevant blocks.
string | UserIdentity | int | null | $specificTarget | |
string | UserIdentity | int | null | $vagueTarget | |
bool | $fromPrimary |
Definition at line 495 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::setBlocker | ( | $user | ) |
Set the user who implemented (or will implement) this block.
UserIdentity | $user |
Definition at line 725 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlock\__construct().
MediaWiki\Block\DatabaseBlock::setId | ( | $blockId | ) |
Set the block ID.
int | $blockId |
Definition at line 373 of file DatabaseBlock.php.
MediaWiki\Block\DatabaseBlock::setRestrictions | ( | array | $restrictions | ) |
Restriction[] | $restrictions |
Definition at line 574 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlock\__construct().
MediaWiki\Block\DatabaseBlock::update | ( | ) |
Update a block in the DB with new parameters.
The ID field needs to be loaded first.
Definition at line 264 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Block\AbstractBlock\getWikiId().
MediaWiki\Block\DatabaseBlock::updateTimestamp | ( | ) |
Update the timestamp on autoblocks.
Definition at line 315 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Block\AbstractBlock\getWikiId().