MediaWiki
1.34.0
|
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may be tracked with cookies. More...
Public Member Functions | ||||
__construct (array $options=[]) | ||||
Create a new block with specified option parameters on a user, IP or IP range. More... | ||||
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 hardblocks, range blocks, and auto-blocks).
| ||||
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 hardblocks, range blocks, and auto-blocks).
| ||||
delete () | ||||
Delete the row from the IP blocks table. More... | ||||
deleteIfExpired () | ||||
Check if a block has expired. More... | ||||
doAutoblock ( $autoblockIP) | ||||
Autoblocks the given IP, referring to this block. More... | ||||
equals (DatabaseBlock $block) | ||||
Check if two blocks are effectively equal. More... | ||||
fromMaster ( $x=null) | ||||
Get/set a flag determining whether the master is used for reads. More... | ||||
getCookieValue () | ||||
Get the BlockID cookie's value for this block. More... | ||||
getId () | ||||
Get the block ID.
| ||||
getParentBlockId () | ||||
getPermissionsError (IContextSource $context) | ||||
Get the key and parameters for the corresponding error message.
| ||||
getRangeEnd () | ||||
Get the IP address at the end of the range in Hex form. More... | ||||
getRangeStart () | ||||
Get the IP address at the start of the range in Hex form. More... | ||||
getRedactedName () | ||||
Get the block name, but with autoblocked IPs hidden as per standard privacy policy. More... | ||||
getRestrictions () | ||||
Get Restrictions. More... | ||||
getType () | ||||
Get the type of target for this particular block.
| ||||
insert (IDatabase $dbw=null) | ||||
Insert a block into the block table. More... | ||||
isAutoblocking ( $x=null) | ||||
isExpired () | ||||
Has the block expired? More... | ||||
isHardblock ( $x=null) | ||||
Get/set whether the block is a hardblock (affects logged-in users on a given IP/range) More... | ||||
isValid () | ||||
Is the block address valid (i.e. More... | ||||
setCookie (WebResponse $response) | ||||
Set the 'BlockID' cookie to this block's ID and expiry time. More... | ||||
setRestrictions (array $restrictions) | ||||
Set Restrictions. More... | ||||
shouldTrackWithCookie ( $isAnon) | ||||
update () | ||||
Update a block in the DB with new parameters. More... | ||||
updateTimestamp () | ||||
Update the timestamp on autoblocks. More... | ||||
Public Member Functions inherited from MediaWiki\Block\AbstractBlock | ||||
appliesToPasswordReset () | ||||
Check if the block prevents a user from resetting their password. More... | ||||
appliesToRight ( $right) | ||||
Determine whether the block prevents a given right. More... | ||||
appliesToUsertalk (Title $usertalk=null) | ||||
Determine whether the block allows the user to edit their own user talk page. More... | ||||
getBlocker () | ||||
Get the user who implemented this block. More... | ||||
getBlockErrorParams (IContextSource $context) | ||||
Get block information used in different block error messages. More... | ||||
getBy () | ||||
Get the user id of the blocking sysop. More... | ||||
getByName () | ||||
Get the username of the blocking sysop. More... | ||||
getExpiry () | ||||
Get the block expiry time. More... | ||||
getHideName () | ||||
Get whether the block hides the target's username. More... | ||||
getReason () | ||||
Get the reason given for creating the block. More... | ||||
getTarget () | ||||
Get the target for this particular block. More... | ||||
getTargetAndType () | ||||
Get the target and target type for this particular block. More... | ||||
getTimestamp () | ||||
Get the timestamp indicating when the block was created. More... | ||||
isCreateAccountBlocked ( $x=null) | ||||
Get or set the flag indicating whether this block blocks the target from creating an account. More... | ||||
isEmailBlocked ( $x=null) | ||||
Get or set the flag indicating whether this block blocks the target from sending emails. More... | ||||
isSitewide ( $x=null) | ||||
Indicates that the block is a sitewide block. More... | ||||
isUsertalkEditAllowed ( $x=null) | ||||
Get or set the flag indicating whether this block blocks the target from editing their own user talk page. More... | ||||
prevents ( $action, $x=null) | ||||
Get/set whether the block prevents a given action. More... | ||||
setBlocker ( $user) | ||||
Set the user who implemented (or will implement) this block. More... | ||||
setExpiry ( $expiry) | ||||
Set the block expiry time. More... | ||||
setHideName ( $hideName) | ||||
Set whether ths block hides the target's username. More... | ||||
setReason ( $reason) | ||||
Set the reason for creating the block. More... | ||||
setTarget ( $target) | ||||
Set the target for this block, and update $this->type accordingly. More... | ||||
setTimestamp ( $timestamp) | ||||
Set the timestamp indicating when the block was created. More... | ||||
Static Public Member Functions | |
static | chooseBlock (array $blocks, array $ipChain) |
From a list of multiple blocks, find the most exact and strongest block. More... | |
static | clearCookie (WebResponse $response) |
Unset the 'BlockID' cookie. More... | |
static | getAutoblockExpiry ( $timestamp) |
Get a timestamp of the expiry for autoblocks. More... | |
static | getBlocksForIPList (array $ipChain, $isAnon, $fromMaster=false) |
Get all blocks that match any IP from an array of IP addresses. More... | |
static | getIdFromCookieValue ( $cookieValue) |
Get the stored ID from the 'BlockID' cookie. More... | |
static | getQueryInfo () |
Return the tables, fields, and join conditions to be selected to create a new block object. More... | |
static | getRangeCond ( $start, $end=null) |
Get a set of SQL conditions which will select rangeblocks encompassing a given range. More... | |
static | isWhitelistedFromAutoblocks ( $ip) |
Checks whether a given IP is on the autoblock whitelist. More... | |
static | newFromID ( $id) |
Load a block from the block id. More... | |
static | newFromRow ( $row) |
Create a new DatabaseBlock object from a database row. More... | |
static | newFromTarget ( $specificTarget, $vagueTarget=null, $fromMaster=false) |
Given a target and the target's type, get an existing block object if possible. More... | |
static | newListFromTarget ( $specificTarget, $vagueTarget=null, $fromMaster=false) |
This is similar to DatabaseBlock::newFromTarget, but it returns all the relevant blocks. More... | |
static | purgeExpired () |
Purge expired blocks from the ipblocks table. More... | |
Static Public Member Functions inherited from MediaWiki\Block\AbstractBlock | |
static | parseTarget ( $target) |
From an existing block, get the target and the type of target. More... | |
Public Attributes | |
bool | $mAuto |
int | $mParentBlockId |
Public Attributes inherited from MediaWiki\Block\AbstractBlock | |
string | $mExpiry = '' |
bool | $mHideName = false |
string | $mReason |
string | $mTimestamp |
const | TYPE_AUTO = 4 |
const | TYPE_ID = 5 |
const | TYPE_IP = 2 |
const | TYPE_RANGE = 3 |
const | TYPE_USER = 1 |
Protected Member Functions | |
doRetroactiveAutoblock () | |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this block. More... | |
getAutoblockUpdateArray (IDatabase $dbw) | |
getDatabaseArray (IDatabase $dbw) | |
Get an array suitable for passing to $dbw->insert() or $dbw->update() More... | |
initFromRow ( $row) | |
Given a database row from the ipblocks table, initialize member variables. More... | |
Static Protected Member Functions | |
static | chooseMostSpecificBlock (array $blocks) |
Choose the most specific block from some combination of user, IP and IP range blocks. More... | |
static | defaultRetroactiveAutoblock (DatabaseBlock $block, array &$blockIds) |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this block. More... | |
static | getIpFragment ( $hex) |
Get the component of an IP address which is certain to be the same between an IP address and a rangeblock containing that IP address. More... | |
static | newLoad ( $specificTarget, $specificType, $fromMaster, $vagueTarget=null) |
Load blocks from the database which target the specific target exactly, or which cover the vague target. More... | |
Private Member Functions | |
findRestriction ( $type, $value) | |
Find Restriction by type and value. More... | |
getBlockRestrictionStore () | |
Get a BlockRestrictionStore instance. More... | |
setId ( $blockId) | |
Set the block ID. More... | |
Private Attributes | |
int | $forcedTargetID |
Hack for foreign blocking (CentralAuth) More... | |
bool | $isAutoblocking |
bool | $isHardblock |
bool | $mFromMaster |
int | $mId |
Restriction[] | $restrictions |
Additional Inherited Members | |
Protected Attributes inherited from MediaWiki\Block\AbstractBlock | |
bool | $allowUsertalk = false |
bool | $blockCreateAccount = false |
User | $blocker |
bool | $isSitewide = true |
bool | $mBlockEmail = false |
User string | $target |
int | $type |
AbstractBlock::TYPE_ constant. More... | |
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 hardblocks, and they may be sitewide or partial.
Definition at line 54 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 103 of file DatabaseBlock.php.
References DB_REPLICA, MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\AbstractBlock\isCreateAccountBlocked(), MediaWiki\Block\AbstractBlock\isEmailBlocked(), MediaWiki\Block\DatabaseBlock\isHardblock(), MediaWiki\Block\AbstractBlock\isSitewide(), MediaWiki\Block\AbstractBlock\isUsertalkEditAllowed(), MediaWiki\Block\AbstractBlock\setExpiry(), and wfGetDB().
MediaWiki\Block\DatabaseBlock::appliesToNamespace | ( | $ns | ) |
Checks if a block applies to a particular namespace.
int | $ns |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 1490 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\findRestriction(), MediaWiki\Block\AbstractBlock\isSitewide(), and MediaWiki\Block\Restriction\NamespaceRestriction\TYPE.
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 hardblocks, range blocks, and auto-blocks).
int | $pageId |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 1508 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\findRestriction(), MediaWiki\Block\AbstractBlock\isSitewide(), and MediaWiki\Block\Restriction\PageRestriction\TYPE.
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 hardblocks, range blocks, and auto-blocks).
Title | $title |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 1472 of file DatabaseBlock.php.
References $title, MediaWiki\Block\DatabaseBlock\getRestrictions(), and MediaWiki\Block\AbstractBlock\isSitewide().
|
static |
From a list of multiple blocks, find the most exact and strongest block.
The logic for finding the "best" block is:
array | $blocks | Array of DatabaseBlock objects |
array | $ipChain | List of IPs (strings). This is used to determine how "close" a block is to the server, and if a block matches exactly, or is in a range. The order is furthest from the server to nearest e.g., (Browser, proxy1, proxy2, local-cdn, ...) |
MWException |
Definition at line 1258 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\appliesToRight(), MediaWiki\Block\DatabaseBlock\isHardblock(), and IP\toHex().
|
staticprotected |
Choose the most specific block from some combination of user, IP and IP range blocks.
Decreasing order of specificity: user > IP > narrower IP range > wider IP range. A range that encompasses one IP address is ranked equally to a singe IP.
Note that DatabaseBlock::chooseBlocks chooses blocks in a different way.
This is refactored out from DatabaseBlock::newLoad.
DatabaseBlock[] | $blocks | These should not include autoblocks or ID blocks |
Definition at line 333 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\$target, IP\isIPv6(), IP\parseCIDR(), and MediaWiki\Block\AbstractBlock\TYPE_RANGE.
Referenced by MediaWiki\Block\DatabaseBlock\newFromTarget().
|
static |
Unset the 'BlockID' cookie.
WebResponse | $response | The response on which to unset the cookie. |
Definition at line 1381 of file DatabaseBlock.php.
References $response, and MediaWiki\MediaWikiServices\getInstance().
|
staticprotected |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this block.
This will use the recentchanges table.
DatabaseBlock | $block | |
array | &$blockIds |
Definition at line 710 of file DatabaseBlock.php.
References $dbr, $res, MediaWiki\Block\AbstractBlock\$target, $wgPutIPinRC, DB_REPLICA, MediaWiki\Block\DatabaseBlock\doAutoblock(), MediaWiki\Block\AbstractBlock\getTarget(), MediaWiki\Block\DatabaseBlock\getType(), ActorMigration\newMigration(), MediaWiki\Block\AbstractBlock\TYPE_USER, wfDebug(), and wfGetDB().
Referenced by MediaWiki\Block\DatabaseBlock\doRetroactiveAutoblock().
MediaWiki\Block\DatabaseBlock::delete | ( | ) |
Delete the row from the IP blocks table.
MWException |
Definition at line 469 of file DatabaseBlock.php.
References DB_MASTER, MediaWiki\Block\DatabaseBlock\getBlockRestrictionStore(), MediaWiki\Block\DatabaseBlock\getId(), wfGetDB(), and wfReadOnly().
MediaWiki\Block\DatabaseBlock::deleteIfExpired | ( | ) |
Check if a block has expired.
Delete it if it is.
Definition at line 885 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\isExpired(), and wfDebug().
MediaWiki\Block\DatabaseBlock::doAutoblock | ( | $autoblockIP | ) |
Autoblocks the given IP, referring to this block.
string | $autoblockIP | The IP to autoblock. |
Definition at line 809 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$mId, $status, MediaWiki\Block\DatabaseBlock\getAutoblockExpiry(), MediaWiki\Block\AbstractBlock\getBlocker(), MediaWiki\Block\AbstractBlock\getExpiry(), MediaWiki\Block\AbstractBlock\getHideName(), MediaWiki\Block\AbstractBlock\getReason(), MediaWiki\Block\DatabaseBlock\getRestrictions(), MediaWiki\Block\AbstractBlock\getTarget(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\AbstractBlock\isCreateAccountBlocked(), MediaWiki\Block\AbstractBlock\isSitewide(), MediaWiki\Block\AbstractBlock\isUsertalkEditAllowed(), MediaWiki\Block\DatabaseBlock\newFromTarget(), Hooks\run(), wfDebug(), wfMessage(), and wfTimestampNow().
Referenced by MediaWiki\Block\DatabaseBlock\defaultRetroactiveAutoblock().
|
protected |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this block.
Definition at line 687 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\defaultRetroactiveAutoblock(), MediaWiki\Block\AbstractBlock\getTarget(), MediaWiki\Block\DatabaseBlock\getType(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), Hooks\run(), and wfDebug().
Referenced by MediaWiki\Block\DatabaseBlock\insert(), and MediaWiki\Block\DatabaseBlock\update().
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 203 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\getBlockRestrictionStore(), MediaWiki\Block\AbstractBlock\getExpiry(), MediaWiki\Block\AbstractBlock\getHideName(), MediaWiki\Block\AbstractBlock\getReason(), 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().
|
private |
Find Restriction by type and value.
string | $type | |
int | $value |
Definition at line 1530 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$restrictions, MediaWiki\Block\AbstractBlock\$type, and MediaWiki\Block\DatabaseBlock\getRestrictions().
Referenced by MediaWiki\Block\DatabaseBlock\appliesToNamespace(), and MediaWiki\Block\DatabaseBlock\appliesToPage().
MediaWiki\Block\DatabaseBlock::fromMaster | ( | $x = null | ) |
Get/set a flag determining whether the master is used for reads.
bool | null | $x |
Definition at line 1023 of file DatabaseBlock.php.
References wfSetVar().
|
static |
Get a timestamp of the expiry for autoblocks.
string | int | $timestamp |
Definition at line 1077 of file DatabaseBlock.php.
References $wgAutoblockExpiry, and wfTimestamp().
Referenced by MediaWiki\Block\DatabaseBlock\doAutoblock().
|
protected |
IDatabase | $dbw |
Definition at line 671 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\getBlocker(), MediaWiki\Block\AbstractBlock\getHideName(), MediaWiki\Block\AbstractBlock\getReason(), CommentStore\getStore(), MediaWiki\Block\AbstractBlock\isCreateAccountBlocked(), MediaWiki\Block\AbstractBlock\isSitewide(), MediaWiki\Block\AbstractBlock\isUsertalkEditAllowed(), and ActorMigration\newMigration().
Referenced by MediaWiki\Block\DatabaseBlock\update().
|
private |
Get a BlockRestrictionStore instance.
Definition at line 1569 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance().
Referenced by MediaWiki\Block\DatabaseBlock\delete(), MediaWiki\Block\DatabaseBlock\equals(), MediaWiki\Block\DatabaseBlock\getRestrictions(), MediaWiki\Block\DatabaseBlock\insert(), MediaWiki\Block\DatabaseBlock\setId(), and MediaWiki\Block\DatabaseBlock\update().
|
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 | $isAnon | Exclude anonymous-only blocks if false |
bool | $fromMaster | Whether to query the master or replica DB |
Definition at line 1177 of file DatabaseBlock.php.
References DB_MASTER, DB_REPLICA, MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Block\DatabaseBlock\getQueryInfo(), MediaWiki\Block\DatabaseBlock\getRangeCond(), IP\isValid(), LIST_OR, MediaWiki\Block\DatabaseBlock\newFromRow(), IP\toHex(), and wfGetDB().
Referenced by MediaWiki\Block\BlockManager\getAdditionalIpBlocks().
MediaWiki\Block\DatabaseBlock::getCookieValue | ( | ) |
Get the BlockID cookie's value for this block.
This is usually the block ID concatenated with an HMAC in order to avoid spoofing (T152951), but if wgSecretKey is not set will just be the block ID.
Definition at line 1395 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance().
|
protected |
Get an array suitable for passing to $dbw->insert() or $dbw->update()
IDatabase | $dbw |
Definition at line 636 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$forcedTargetID, MediaWiki\Block\DatabaseBlock\$mParentBlockId, Wikimedia\Rdbms\IDatabase\encodeExpiry(), MediaWiki\Block\AbstractBlock\getBlocker(), MediaWiki\Block\AbstractBlock\getExpiry(), MediaWiki\Block\AbstractBlock\getHideName(), User\getId(), MediaWiki\Block\DatabaseBlock\getRangeEnd(), MediaWiki\Block\DatabaseBlock\getRangeStart(), MediaWiki\Block\AbstractBlock\getReason(), CommentStore\getStore(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\AbstractBlock\isCreateAccountBlocked(), MediaWiki\Block\AbstractBlock\isEmailBlocked(), MediaWiki\Block\DatabaseBlock\isHardblock(), MediaWiki\Block\AbstractBlock\isSitewide(), MediaWiki\Block\AbstractBlock\isUsertalkEditAllowed(), ActorMigration\newMigration(), and Wikimedia\Rdbms\IDatabase\timestamp().
Referenced by MediaWiki\Block\DatabaseBlock\insert(), and MediaWiki\Block\DatabaseBlock\update().
MediaWiki\Block\DatabaseBlock::getId | ( | ) |
Get the block ID.
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 987 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$mId.
Referenced by MediaWiki\Block\DatabaseBlock\delete(), MediaWiki\Block\BlockManager\getCookieValue(), MediaWiki\Block\DatabaseBlock\update(), and MediaWiki\Block\DatabaseBlock\updateTimestamp().
|
static |
Get the stored ID from the 'BlockID' cookie.
The cookie's value is usually a combination of the ID and a HMAC (see DatabaseBlock::setCookie), but will sometimes only be the ID.
string | $cookieValue | The string in which to find the ID. |
Definition at line 1408 of file DatabaseBlock.php.
References MediaWiki\MediaWikiServices\getInstance().
|
staticprotected |
Get the component of an IP address which is certain to be the same between an IP address and a rangeblock containing that IP address.
string | $hex | Hexadecimal IP representation |
Definition at line 408 of file DatabaseBlock.php.
References $wgBlockCIDRLimit.
Referenced by MediaWiki\Block\DatabaseBlock\getRangeCond().
MediaWiki\Block\DatabaseBlock::getParentBlockId | ( | ) |
Definition at line 1013 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$mParentBlockId.
MediaWiki\Block\DatabaseBlock::getPermissionsError | ( | IContextSource | $context | ) |
Get the key and parameters for the corresponding error message.
IContextSource | $context |
Build different messages for autoblocks and partial blocks.
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 1417 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\getBlockErrorParams(), and MediaWiki\Block\AbstractBlock\isSitewide().
|
static |
Return the tables, fields, and join conditions to be selected to create a new block object.
$table
to IDatabase->select()
$vars
to IDatabase->select()
$join_conds
to IDatabase->select()
Definition at line 172 of file DatabaseBlock.php.
References CommentStore\getStore(), and ActorMigration\newMigration().
Referenced by MediaWiki\Block\DatabaseBlock\getBlocksForIPList(), MediaWiki\Block\DatabaseBlock\newFromID(), and MediaWiki\Block\DatabaseBlock\newLoad().
|
static |
Get a set of SQL conditions which will select rangeblocks encompassing a given range.
string | $start | Hexadecimal IP representation |
string | null | $end | Hexadecimal IP representation, or null to use $start = $end |
Definition at line 375 of file DatabaseBlock.php.
References $dbr, DB_REPLICA, MediaWiki\Block\DatabaseBlock\getIpFragment(), LIST_AND, and wfGetDB().
Referenced by MediaWiki\Block\DatabaseBlock\getBlocksForIPList(), and MediaWiki\Block\DatabaseBlock\newLoad().
MediaWiki\Block\DatabaseBlock::getRangeEnd | ( | ) |
Get the IP address at the end of the range in Hex form.
MWException |
Definition at line 970 of file DatabaseBlock.php.
References IP\parseRange(), IP\toHex(), MediaWiki\Block\AbstractBlock\TYPE_IP, MediaWiki\Block\AbstractBlock\TYPE_RANGE, and MediaWiki\Block\AbstractBlock\TYPE_USER.
Referenced by MediaWiki\Block\DatabaseBlock\getDatabaseArray().
MediaWiki\Block\DatabaseBlock::getRangeStart | ( | ) |
Get the IP address at the start of the range in Hex form.
MWException |
Definition at line 951 of file DatabaseBlock.php.
References IP\parseRange(), IP\toHex(), MediaWiki\Block\AbstractBlock\TYPE_IP, MediaWiki\Block\AbstractBlock\TYPE_RANGE, and MediaWiki\Block\AbstractBlock\TYPE_USER.
Referenced by MediaWiki\Block\DatabaseBlock\getDatabaseArray().
MediaWiki\Block\DatabaseBlock::getRedactedName | ( | ) |
Get the block name, but with autoblocked IPs hidden as per standard privacy policy.
Definition at line 1059 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\getTarget(), and wfMessage().
MediaWiki\Block\DatabaseBlock::getRestrictions | ( | ) |
Get Restrictions.
Getting the restrictions will perform a database query if the restrictions are not already loaded.
Definition at line 1441 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$restrictions, and MediaWiki\Block\DatabaseBlock\getBlockRestrictionStore().
Referenced by MediaWiki\Block\DatabaseBlock\appliesToTitle(), MediaWiki\Block\DatabaseBlock\doAutoblock(), MediaWiki\Block\DatabaseBlock\equals(), and MediaWiki\Block\DatabaseBlock\findRestriction().
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 1356 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\TYPE_AUTO.
Referenced by MediaWiki\Block\DatabaseBlock\defaultRetroactiveAutoblock(), MediaWiki\Block\DatabaseBlock\doRetroactiveAutoblock(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\DatabaseBlock\isHardblock(), SpecialBlock\maybeAlterFormDefaults(), MediaWiki\Block\BlockManager\shouldApplyCookieBlock(), and MediaWiki\Block\DatabaseBlock\shouldTrackWithCookie().
|
protected |
Given a database row from the ipblocks table, initialize member variables.
stdClass | $row | A row from the ipblocks table |
Definition at line 422 of file DatabaseBlock.php.
References DB_REPLICA, CommentStore\getStore(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\AbstractBlock\isCreateAccountBlocked(), MediaWiki\Block\AbstractBlock\isEmailBlocked(), MediaWiki\Block\DatabaseBlock\isHardblock(), MediaWiki\Block\AbstractBlock\isSitewide(), MediaWiki\Block\AbstractBlock\isUsertalkEditAllowed(), User\newFromAnyId(), MediaWiki\Block\AbstractBlock\setBlocker(), MediaWiki\Block\AbstractBlock\setExpiry(), MediaWiki\Block\AbstractBlock\setHideName(), MediaWiki\Block\AbstractBlock\setReason(), MediaWiki\Block\AbstractBlock\setTarget(), MediaWiki\Block\AbstractBlock\setTimestamp(), wfGetDB(), and wfTimestamp().
Referenced by MediaWiki\Block\DatabaseBlock\newFromRow().
MediaWiki\Block\DatabaseBlock::insert | ( | IDatabase | $dbw = null | ) |
Insert a block into the block table.
Will fail if there is a conflicting block (same name and options) already in the database.
IDatabase | null | $dbw | If you have one available |
Definition at line 499 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$mId, $wgBlockDisablesLogin, DB_MASTER, MediaWiki\Block\DatabaseBlock\doRetroactiveAutoblock(), MediaWiki\Block\AbstractBlock\getBlocker(), MediaWiki\Block\DatabaseBlock\getBlockRestrictionStore(), MediaWiki\Block\DatabaseBlock\getDatabaseArray(), MediaWiki\Block\DatabaseBlock\purgeExpired(), MediaWiki\Block\DatabaseBlock\setId(), wfDebug(), and wfGetDB().
MediaWiki\Block\DatabaseBlock::isAutoblocking | ( | $x = null | ) |
null | bool | $x |
Definition at line 1045 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\getType(), and wfSetVar().
Referenced by MediaWiki\Block\DatabaseBlock\__construct(), MediaWiki\Block\DatabaseBlock\doAutoblock(), MediaWiki\Block\DatabaseBlock\doRetroactiveAutoblock(), MediaWiki\Block\DatabaseBlock\equals(), MediaWiki\Block\DatabaseBlock\getDatabaseArray(), MediaWiki\Block\DatabaseBlock\initFromRow(), MediaWiki\Block\BlockManager\shouldApplyCookieBlock(), MediaWiki\Block\DatabaseBlock\shouldTrackWithCookie(), and MediaWiki\Block\DatabaseBlock\update().
MediaWiki\Block\DatabaseBlock::isExpired | ( | ) |
Has the block expired?
Definition at line 902 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\getExpiry(), wfDebug(), and wfTimestampNow().
Referenced by MediaWiki\Block\DatabaseBlock\deleteIfExpired(), and MediaWiki\Block\BlockManager\shouldApplyCookieBlock().
MediaWiki\Block\DatabaseBlock::isHardblock | ( | $x = null | ) |
Get/set whether the block is a hardblock (affects logged-in users on a given IP/range)
bool | null | $x |
Definition at line 1032 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$isHardblock, MediaWiki\Block\DatabaseBlock\getType(), true, and wfSetVar().
Referenced by MediaWiki\Block\DatabaseBlock\__construct(), MediaWiki\Block\DatabaseBlock\chooseBlock(), MediaWiki\Block\DatabaseBlock\equals(), MediaWiki\Block\DatabaseBlock\getDatabaseArray(), and MediaWiki\Block\DatabaseBlock\initFromRow().
MediaWiki\Block\DatabaseBlock::isValid | ( | ) |
Is the block address valid (i.e.
not a null string?)
Definition at line 919 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\getTarget(), and wfDeprecated().
|
static |
Checks whether a given IP is on the autoblock whitelist.
TODO: this probably belongs somewhere else, but not sure where...
string | $ip | The IP to check |
Definition at line 763 of file DatabaseBlock.php.
References $cache, $line, $lines, DB_REPLICA, Wikimedia\Rdbms\Database\getCacheSetOptions(), MediaWiki\MediaWikiServices\getInstance(), IP\isInRange(), wfDebug(), wfGetDB(), and wfMessage().
|
static |
Load a block from the block id.
int | $id | id to search for |
Definition at line 145 of file DatabaseBlock.php.
References $dbr, $res, DB_REPLICA, MediaWiki\Block\DatabaseBlock\getQueryInfo(), MediaWiki\Block\DatabaseBlock\newFromRow(), and wfGetDB().
Referenced by MediaWiki\Block\BlockManager\getBlockFromCookieValue(), and MediaWiki\Block\DatabaseBlock\newListFromTarget().
|
static |
Create a new DatabaseBlock object from a database row.
stdClass | $row | Row from the ipblocks table |
Definition at line 457 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\initFromRow().
Referenced by MediaWiki\Block\DatabaseBlock\getBlocksForIPList(), MediaWiki\Block\DatabaseBlock\newFromID(), and MediaWiki\Block\DatabaseBlock\newLoad().
|
static |
Given a target and the target's type, get an existing block object if possible.
string | User | int | $specificTarget | A block target, which may be one of several types:
|
string | User | 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 | $fromMaster | Whether to use the DB_MASTER database |
Definition at line 1130 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\chooseMostSpecificBlock(), and MediaWiki\Block\DatabaseBlock\newListFromTarget().
Referenced by MediaWiki\Block\DatabaseBlock\doAutoblock().
|
static |
This is similar to DatabaseBlock::newFromTarget, but it returns all the relevant blocks.
string | User | int | null | $specificTarget | |
string | User | int | null | $vagueTarget | |
bool | $fromMaster |
Definition at line 1144 of file DatabaseBlock.php.
References MediaWiki\Block\AbstractBlock\$target, MediaWiki\Block\AbstractBlock\$type, MediaWiki\Block\DatabaseBlock\newFromID(), MediaWiki\Block\DatabaseBlock\newLoad(), and MediaWiki\Block\AbstractBlock\parseTarget().
Referenced by MediaWiki\Block\BlockManager\getUserBlock(), and MediaWiki\Block\DatabaseBlock\newFromTarget().
|
staticprotected |
Load blocks from the database which target the specific target exactly, or which cover the vague target.
User | string | null | $specificTarget | |
int | null | $specificType | |
bool | $fromMaster | |
User | string | null | $vagueTarget | Also search for blocks affecting this target. Doesn't make any sense to use TYPE_AUTO / TYPE_ID here. Leave blank to skip IP lookups. |
MWException |
Definition at line 237 of file DatabaseBlock.php.
References $res, MediaWiki\Block\AbstractBlock\$target, MediaWiki\Block\AbstractBlock\$type, DB_MASTER, DB_REPLICA, MediaWiki\Block\DatabaseBlock\getQueryInfo(), MediaWiki\Block\DatabaseBlock\getRangeCond(), LIST_OR, MediaWiki\Block\DatabaseBlock\newFromRow(), IP\parseRange(), MediaWiki\Block\AbstractBlock\parseTarget(), IP\toHex(), MediaWiki\Block\AbstractBlock\TYPE_AUTO, MediaWiki\Block\AbstractBlock\TYPE_IP, MediaWiki\Block\AbstractBlock\TYPE_RANGE, MediaWiki\Block\AbstractBlock\TYPE_USER, and wfGetDB().
Referenced by MediaWiki\Block\DatabaseBlock\newListFromTarget().
|
static |
Purge expired blocks from the ipblocks table.
Definition at line 1086 of file DatabaseBlock.php.
References Wikimedia\Rdbms\IDatabase\addQuotes(), DeferredUpdates\addUpdate(), DB_MASTER, Wikimedia\Rdbms\IDatabase\delete(), MediaWiki\MediaWikiServices\getInstance(), Wikimedia\Rdbms\IDatabase\selectFieldValues(), Wikimedia\Rdbms\IDatabase\timestamp(), wfGetDB(), and wfReadOnly().
Referenced by MediaWiki\Block\DatabaseBlock\insert().
MediaWiki\Block\DatabaseBlock::setCookie | ( | WebResponse | $response | ) |
Set the 'BlockID' cookie to this block's ID and expiry time.
The cookie's expiry will be the same as the block's, to a maximum of 24 hours.
WebResponse | $response | The response on which to set the cookie. |
Definition at line 1370 of file DatabaseBlock.php.
References $response, and MediaWiki\MediaWikiServices\getInstance().
|
private |
Set the block ID.
int | $blockId |
Definition at line 997 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\getBlockRestrictionStore().
Referenced by MediaWiki\Block\DatabaseBlock\insert().
MediaWiki\Block\DatabaseBlock::setRestrictions | ( | array | $restrictions | ) |
Set Restrictions.
Restriction[] | $restrictions |
Definition at line 1461 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$restrictions.
MediaWiki\Block\DatabaseBlock::shouldTrackWithCookie | ( | $isAnon | ) |
Check if the block should be tracked with a cookie.
bool | $isAnon | The user is logged out |
Reimplemented from MediaWiki\Block\AbstractBlock.
Definition at line 1550 of file DatabaseBlock.php.
References MediaWiki\$config, Config\get(), RequestContext\getMain(), MediaWiki\Block\DatabaseBlock\getType(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\AbstractBlock\TYPE_IP, MediaWiki\Block\AbstractBlock\TYPE_RANGE, MediaWiki\Block\AbstractBlock\TYPE_USER, and wfDeprecated().
MediaWiki\Block\DatabaseBlock::update | ( | ) |
Update a block in the DB with new parameters.
The ID field needs to be loaded first.
Definition at line 573 of file DatabaseBlock.php.
References MediaWiki\Block\DatabaseBlock\$mId, $success, DB_MASTER, MediaWiki\Block\DatabaseBlock\doRetroactiveAutoblock(), MediaWiki\Block\DatabaseBlock\getAutoblockUpdateArray(), MediaWiki\Block\DatabaseBlock\getBlockRestrictionStore(), MediaWiki\Block\DatabaseBlock\getDatabaseArray(), MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), wfDebug(), and wfGetDB().
MediaWiki\Block\DatabaseBlock::updateTimestamp | ( | ) |
Update the timestamp on autoblocks.
Definition at line 927 of file DatabaseBlock.php.
References DB_MASTER, MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\AbstractBlock\getTimestamp(), MediaWiki\Block\AbstractBlock\setExpiry(), MediaWiki\Block\AbstractBlock\setTimestamp(), wfGetDB(), and wfTimestamp().
|
private |
Hack for foreign blocking (CentralAuth)
Definition at line 74 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlock\getDatabaseArray().
|
private |
Definition at line 80 of file DatabaseBlock.php.
|
private |
Definition at line 77 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlock\isHardblock().
bool MediaWiki\Block\DatabaseBlock::$mAuto |
Use getType to check whether a block is autoblocking.
Definition at line 59 of file DatabaseBlock.php.
|
private |
Definition at line 71 of file DatabaseBlock.php.
|
private |
Definition at line 68 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlock\doAutoblock(), MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\DatabaseBlock\insert(), and MediaWiki\Block\DatabaseBlock\update().
int MediaWiki\Block\DatabaseBlock::$mParentBlockId |
Use getParentBlockId instead.
Definition at line 65 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlock\getDatabaseArray(), and MediaWiki\Block\DatabaseBlock\getParentBlockId().
|
private |
Definition at line 83 of file DatabaseBlock.php.
Referenced by MediaWiki\Block\DatabaseBlock\findRestriction(), MediaWiki\Block\DatabaseBlock\getRestrictions(), and MediaWiki\Block\DatabaseBlock\setRestrictions().