MediaWiki REL1_33
|
Public Member Functions | |
__construct ( $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. | |
appliesToPage ( $pageId) | |
Checks if a block applies to a particular page. | |
appliesToPasswordReset () | |
Check if the block prevents a user from resetting their password. | |
appliesToRight ( $right) | |
Determine whether the Block prevents a given right. | |
appliesToTitle (Title $title) | |
Checks if a block applies to a particular title. | |
appliesToUsertalk (Title $usertalk=null) | |
Determine whether the block allows the user to edit their own user talk page. | |
delete () | |
Delete the row from the IP blocks table. | |
deleteIfExpired () | |
Check if a block has expired. | |
doAutoblock ( $autoblockIP) | |
Autoblocks the given IP, referring to this Block. | |
equals (Block $block) | |
Check if two blocks are effectively equal. | |
fromMaster ( $x=null) | |
Get/set a flag determining whether the master is used for reads. | |
getBlocker () | |
Get the user who implemented this block. | |
getBlockErrorParams (IContextSource $context) | |
Get block information used in different block error messages. | |
getBy () | |
Get the user id of the blocking sysop. | |
getByName () | |
Get the username of the blocking sysop. | |
getCookieValue () | |
Get the BlockID cookie's value for this block. | |
getExpiry () | |
Get the block expiry time. | |
getHideName () | |
Get whether the block hides the target's username. | |
getId () | |
Get the block ID. | |
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. | |
getRangeStart () | |
Get the IP address at the start of the range in Hex form. | |
getReason () | |
Get the reason given for creating the block. | |
getRedactedName () | |
Get the block name, but with autoblocked IPs hidden as per standard privacy policy. | |
getRestrictions () | |
Get Restrictions. | |
getSystemBlockType () | |
Get the system block type, if any. | |
getTarget () | |
Get the target for this particular Block. | |
getTargetAndType () | |
Get the target and target type for this particular Block. | |
getTimestamp () | |
Get the timestamp indicating when the block was created. | |
getType () | |
Get the type of target for this particular block. | |
insert ( $dbw=null) | |
Insert a block into the block table. | |
isAutoblocking ( $x=null) | |
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. | |
isExpired () | |
Has the block expired? | |
isHardblock ( $x=null) | |
Get/set whether the Block is a hardblock (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. | |
isValid () | |
Is the block address valid (i.e. | |
prevents ( $action, $x=null) | |
Get/set whether the Block prevents a given action. | |
setBlocker ( $user) | |
Set the user who implemented (or will implement) this block. | |
setCookie (WebResponse $response) | |
Set the 'BlockID' cookie to this block's ID and expiry time. | |
setExpiry ( $expiry) | |
Set the block expiry time. | |
setHideName ( $hideName) | |
Set whether ths block hides the target's username. | |
setReason ( $reason) | |
Set the reason for creating the block. | |
setRestrictions (array $restrictions) | |
Set Restrictions. | |
setTarget ( $target) | |
Set the target for this block, and update $this->type accordingly. | |
setTimestamp ( $timestamp) | |
Set the timestamp indicating when the block was created. | |
shouldTrackWithCookie ( $isIpUser) | |
Check if the block should be tracked with a cookie. | |
update () | |
Update a block in the DB with new parameters. | |
updateTimestamp () | |
Update the timestamp on autoblocks. | |
Static Public Member Functions | |
static | chooseBlock (array $blocks, array $ipChain) |
From a list of multiple blocks, find the most exact and strongest Block. | |
static | clearCookie (WebResponse $response) |
Unset the 'BlockID' cookie. | |
static | getAutoblockExpiry ( $timestamp) |
Get a timestamp of the expiry for autoblocks. | |
static | getBlocksForIPList (array $ipChain, $isAnon, $fromMaster=false) |
Get all blocks that match any IP from an array of IP addresses. | |
static | getIdFromCookieValue ( $cookieValue) |
Get the stored ID from the 'BlockID' cookie. | |
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 rangeblocks encompassing a given range. | |
static | isWhitelistedFromAutoblocks ( $ip) |
Checks whether a given IP is on the autoblock whitelist. | |
static | newFromID ( $id) |
Load a block from the block id. | |
static | newFromRow ( $row) |
Create a new Block object from a database row. | |
static | newFromTarget ( $specificTarget, $vagueTarget=null, $fromMaster=false) |
Given a target and the target's type, get an existing Block object if possible. | |
static | parseTarget ( $target) |
From an existing Block, get the target and the type of target. | |
static | purgeExpired () |
Purge expired blocks from the ipblocks table. | |
static | selectFields () |
Return the list of ipblocks fields that should be selected to create a new block. | |
Public Attributes | |
bool | $mAuto |
string | $mExpiry |
bool | $mHideName |
int | $mParentBlockId |
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. | |
getAutoblockUpdateArray (IDatabase $dbw) | |
getDatabaseArray (IDatabase $dbw) | |
Get an array suitable for passing to $dbw->insert() or $dbw->update() | |
initFromRow ( $row) | |
Given a database row from the ipblocks table, initialize member variables. | |
newLoad ( $vagueTarget=null) | |
Load a block from the database which affects the already-set $this->target: 1) A block directly on the given user or IP 2) A rangeblock encompassing the given IP (smallest first) 3) An autoblock on the given IP. | |
Static Protected Member Functions | |
static | defaultRetroactiveAutoblock (Block $block, array &$blockIds) |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block. | |
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. | |
Private Member Functions | |
findRestriction ( $type, $value) | |
Find Restriction by type and value. | |
getBlockRestrictionStore () | |
Get a BlockRestrictionStore instance. | |
setId ( $blockId) | |
Set the block ID. | |
Private Attributes | |
bool | $allowUsertalk |
bool | $blockCreateAccount |
User | $blocker |
int | $forcedTargetID |
Hack for foreign blocking (CentralAuth) | |
bool | $isAutoblocking |
bool | $isHardblock |
bool | $isSitewide |
bool | $mBlockEmail |
bool | $mFromMaster |
int | $mId |
Restriction[] | $restrictions |
string null | $systemBlockType |
User string | $target |
int | $type |
Block::TYPE_ constant. | |
Block::__construct | ( | $options = [] | ) |
Create a new block with specified parameters on a user, IP or IP range.
array | $options | Parameters of the block: address string|User Target user name, User object, IP address or IP range user int Override target user ID (for foreign users) by int User ID of the blocker reason string Reason of the block timestamp string The time at which the block comes into effect auto bool Is this an automatic block? expiry string Timestamp of expiration of the block or 'infinity' anonOnly bool Only disallow anonymous actions createAccount bool Disallow creation of new accounts enableAutoblock bool Enable automatic blocking hideName bool Hide the target user name blockEmail bool Disallow sending emails allowUsertalk bool Allow the target to edit its own talk page byText string Username of the blocker (for foreign users) systemBlock string Indicate that this block is automatically created by MediaWiki rather than being stored in the database. Value is a string to return from self::getSystemBlockType(). sitewide bool Disallow editing all pages and all contribution actions, except those specifically allowed by other block flags |
Definition at line 131 of file Block.php.
References $options, and(), DB_REPLICA, isAutoblocking(), isCreateAccountBlocked(), isEmailBlocked(), isHardblock(), isSitewide(), isUsertalkEditAllowed(), User\newFromId(), setBlocker(), setExpiry(), setHideName(), setReason(), setTarget(), setTimestamp(), wfGetDB(), and wfTimestamp().
Block::appliesToNamespace | ( | $ns | ) |
Checks if a block applies to a particular namespace.
int | $ns |
Definition at line 2066 of file Block.php.
References and(), findRestriction(), and isSitewide().
Referenced by appliesToUsertalk().
Block::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 |
Definition at line 2094 of file Block.php.
References and(), findRestriction(), and isSitewide().
Referenced by appliesToUsertalk().
Block::appliesToPasswordReset | ( | ) |
Check if the block prevents a user from resetting their password.
Definition at line 2157 of file Block.php.
References getSystemBlockType(), and isCreateAccountBlocked().
Block::appliesToRight | ( | $right | ) |
Determine whether the Block prevents a given right.
A right may be blacklisted or whitelisted, or determined from a property on the Block object. For certain rights, the property may be overridden according to global configs.
string | $right | Right to check |
Definition at line 1231 of file Block.php.
References $res, User\isAllowed(), isCreateAccountBlocked(), isEmailBlocked(), and isSitewide().
Referenced by User\isBlocked(), and User\isBlockedFromCreateAccount().
Block::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 |
Definition at line 2043 of file Block.php.
References getRestrictions(), and isSitewide().
Determine whether the block allows the user to edit their own user talk page.
This is done separately from Block::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 ipb_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).
Title | null | $usertalk | The user's user talk page. If null, and if the target is a User, the target's userpage is used |
Definition at line 1997 of file Block.php.
References appliesToNamespace(), appliesToPage(), isSitewide(), isUsertalkEditAllowed(), and NS_USER_TALK.
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 Block 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-squid, ...) |
MWException |
Definition at line 1523 of file Block.php.
Referenced by User\getBlockedStatus(), and BlockTest\testBlocksOnXff().
|
static |
Unset the 'BlockID' cookie.
WebResponse | $response | The response on which to unset the cookie. |
Definition at line 1815 of file Block.php.
References $response.
Referenced by User\getBlockFromCookieValue().
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block.
This will use the recentchanges table.
Block | $block | |
array | &$blockIds |
Definition at line 759 of file Block.php.
References $dbr, $options, $res, $target, $wgPutIPinRC, DB_REPLICA, doAutoblock(), getTarget(), getType(), wfDebug(), and wfGetDB().
Referenced by doRetroactiveAutoblock().
Block::delete | ( | ) |
Delete the row from the IP blocks table.
MWException |
Definition at line 517 of file Block.php.
References DB_MASTER, getBlockRestrictionStore(), getId(), wfGetDB(), and wfReadOnly().
Block::deleteIfExpired | ( | ) |
Check if a block has expired.
Delete it if it is.
Definition at line 939 of file Block.php.
References and(), isExpired(), and wfDebug().
Block::doAutoblock | ( | $autoblockIP | ) |
Autoblocks the given IP, referring to this Block.
string | $autoblockIP | The IP to autoblock. |
Definition at line 858 of file Block.php.
References $mId, and(), getBlocker(), getExpiry(), getHideName(), getReason(), getRestrictions(), getSystemBlockType(), getTarget(), isAutoblocking(), isCreateAccountBlocked(), isSitewide(), isUsertalkEditAllowed(), newFromTarget(), plain, wfDebug(), wfMessage(), and wfTimestampNow().
Referenced by defaultRetroactiveAutoblock().
|
protected |
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block.
Definition at line 736 of file Block.php.
References and(), defaultRetroactiveAutoblock(), getTarget(), getType(), isAutoblocking(), and wfDebug().
Block::equals | ( | Block | $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
Block | $block |
Definition at line 292 of file Block.php.
References getExpiry(), getHideName(), getReason(), getRestrictions(), isAutoblocking(), isCreateAccountBlocked(), isEmailBlocked(), isHardblock(), isSitewide(), and isUsertalkEditAllowed().
|
private |
Find Restriction by type and value.
string | $type | |
int | $value |
Definition at line 2116 of file Block.php.
References $restrictions, $type, $value, and(), and getRestrictions().
Referenced by appliesToNamespace(), and appliesToPage().
Block::fromMaster | ( | $x = null | ) |
Get/set a flag determining whether the master is used for reads.
bool | null | $x |
Definition at line 1137 of file Block.php.
References wfSetVar().
|
static |
Get a timestamp of the expiry for autoblocks.
string | int | $timestamp |
Definition at line 1350 of file Block.php.
References $wgAutoblockExpiry, and wfTimestamp().
|
protected |
IDatabase | $dbw |
Definition at line 720 of file Block.php.
References and(), getBlocker(), getHideName(), getReason(), isCreateAccountBlocked(), isSitewide(), and isUsertalkEditAllowed().
Referenced by update().
Block::getBlocker | ( | ) |
Get the user who implemented this block.
Definition at line 1761 of file Block.php.
References $blocker.
Referenced by doAutoblock(), getAutoblockUpdateArray(), getBlockErrorParams(), getBy(), getByName(), getDatabaseArray(), and insert().
Block::getBlockErrorParams | ( | IContextSource | $context | ) |
Get block information used in different block error messages.
IContextSource | $context |
Definition at line 1902 of file Block.php.
References $blocker, $context, $lang, $link, $systemBlockType, getBlocker(), getByName(), getExpiry(), getId(), IContextSource\getLanguage(), getReason(), getSystemBlockType(), getTarget(), User\getUserPage(), and string.
Referenced by getPermissionsError().
|
private |
|
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 1442 of file Block.php.
References $rows, and(), DB_MASTER, DB_REPLICA, getQueryInfo(), getRangeCond(), LIST_OR, newFromRow(), and wfGetDB().
Referenced by User\getBlockedStatus(), and BlockTest\testBlocksOnXff().
Block::getBy | ( | ) |
Get the user id of the blocking sysop.
Definition at line 1043 of file Block.php.
References getBlocker().
Referenced by ApiQueryUserInfo\getBlockInfo().
Block::getByName | ( | ) |
Get the username of the blocking sysop.
Definition at line 1052 of file Block.php.
References getBlocker().
Referenced by getBlockErrorParams(), and ApiQueryUserInfo\getBlockInfo().
Block::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 1828 of file Block.php.
References and(), getId(), and MWCryptHash\hmac().
Referenced by setCookie().
|
protected |
Get an array suitable for passing to $dbw->insert() or $dbw->update()
IDatabase | $dbw |
Definition at line 685 of file Block.php.
References $forcedTargetID, $mParentBlockId, and(), Wikimedia\Rdbms\IDatabase\encodeExpiry(), getBlocker(), getExpiry(), getHideName(), User\getId(), getRangeEnd(), getRangeStart(), getReason(), isAutoblocking(), isCreateAccountBlocked(), isEmailBlocked(), isHardblock(), isSitewide(), isUsertalkEditAllowed(), string, and Wikimedia\Rdbms\IDatabase\timestamp().
Block::getExpiry | ( | ) |
Get the block expiry time.
Definition at line 1715 of file Block.php.
References $mExpiry.
Referenced by doAutoblock(), equals(), getBlockErrorParams(), ApiQueryUserInfo\getBlockInfo(), getDatabaseArray(), isExpired(), and setCookie().
Block::getHideName | ( | ) |
Get whether the block hides the target's username.
Definition at line 1108 of file Block.php.
References $mHideName.
Referenced by doAutoblock(), equals(), getAutoblockUpdateArray(), and getDatabaseArray().
Block::getId | ( | ) |
Get the block ID.
Definition at line 1060 of file Block.php.
References $mId.
Referenced by delete(), getBlockErrorParams(), ApiQueryUserInfo\getBlockInfo(), getCookieValue(), and update().
|
static |
Get the stored ID from the 'BlockID' cookie.
The cookie's value is usually a combination of the ID and a HMAC (see Block::setCookie), but will sometimes only be the ID.
string | $cookieValue | The string in which to find the ID. |
Definition at line 1851 of file Block.php.
References and(), false, and MWCryptHash\hmac().
Referenced by User\getBlockFromCookieValue(), and UserTest\testAutoblockCookies().
|
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 456 of file Block.php.
References $wgBlockCIDRLimit, and and().
Referenced by getRangeCond().
Block::getPermissionsError | ( | IContextSource | $context | ) |
Get the key and parameters for the corresponding error message.
IContextSource | $context |
Definition at line 1878 of file Block.php.
References $params, and(), getBlockErrorParams(), getSystemBlockType(), and isSitewide().
Referenced by UserBlockedError\__construct().
|
static |
Return the tables, fields, and join conditions to be selected to create a new block object.
Definition at line 260 of file Block.php.
Referenced by CleanupBlocks\execute(), getBlocksForIPList(), newFromID(), newLoad(), and BlockTest\testNewFromRow().
|
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 423 of file Block.php.
References $dbr, DB_REPLICA, getIpFragment(), LIST_AND, and wfGetDB().
Referenced by SpecialBlockList\getBlockListPager(), getBlocksForIPList(), and newLoad().
Block::getRangeEnd | ( | ) |
Get the IP address at the end of the range in Hex form.
MWException |
Definition at line 1024 of file Block.php.
References list, type, TYPE_IP, TYPE_RANGE, and TYPE_USER.
Referenced by getDatabaseArray().
Block::getRangeStart | ( | ) |
Get the IP address at the start of the range in Hex form.
MWException |
Definition at line 1005 of file Block.php.
References list, type, TYPE_IP, TYPE_RANGE, and TYPE_USER.
Referenced by getDatabaseArray().
Block::getReason | ( | ) |
Get the reason given for creating the block.
Definition at line 1088 of file Block.php.
References $mReason.
Referenced by doAutoblock(), equals(), getAutoblockUpdateArray(), getBlockErrorParams(), ApiQueryUserInfo\getBlockInfo(), and getDatabaseArray().
Block::getRedactedName | ( | ) |
Get the block name, but with autoblocked IPs hidden as per standard privacy policy.
Definition at line 1332 of file Block.php.
References and(), getTarget(), text, and wfMessage().
Block::getRestrictions | ( | ) |
Get Restrictions.
Getting the restrictions will perform a database query if the restrictions are not already loaded.
Definition at line 1943 of file Block.php.
References $restrictions, and getBlockRestrictionStore().
Referenced by appliesToTitle(), doAutoblock(), equals(), and findRestriction().
Block::getSystemBlockType | ( | ) |
Get the system block type, if any.
Definition at line 1127 of file Block.php.
References $systemBlockType.
Referenced by appliesToPasswordReset(), doAutoblock(), getBlockErrorParams(), ApiQueryUserInfo\getBlockInfo(), getPermissionsError(), and insert().
Block::getTarget | ( | ) |
Get the target for this particular Block.
Note that for autoblocks, this returns the unredacted name; frontend functions need to call $block->getRedactedName() in this situation.
Definition at line 1705 of file Block.php.
References $target.
Referenced by defaultRetroactiveAutoblock(), doAutoblock(), doRetroactiveAutoblock(), getBlockErrorParams(), getRedactedName(), getTargetAndType(), and isValid().
Block::getTargetAndType | ( | ) |
Get the target and target type for this particular Block.
Note that for autoblocks, this returns the unredacted name; frontend functions need to call $block->getRedactedName() in this situation.
Definition at line 1695 of file Block.php.
References getTarget(), and getType().
Block::getTimestamp | ( | ) |
Get the timestamp indicating when the block was created.
Definition at line 1735 of file Block.php.
References $mTimestamp.
Referenced by ApiQueryUserInfo\getBlockInfo(), and updateTimestamp().
Block::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.
Definition at line 1682 of file Block.php.
References $type, and TYPE_AUTO.
Referenced by defaultRetroactiveAutoblock(), ApiBase\dieBlocked(), doRetroactiveAutoblock(), getTargetAndType(), isAutoblocking(), isHardblock(), SpecialBlock\maybeAlterFormDefaults(), and shouldTrackWithCookie().
|
protected |
Given a database row from the ipblocks table, initialize member variables.
stdClass | $row | A row from the ipblocks table |
Definition at line 470 of file Block.php.
References and(), DB_REPLICA, isAutoblocking(), isCreateAccountBlocked(), isEmailBlocked(), isHardblock(), isSitewide(), isUsertalkEditAllowed(), User\newFromAnyId(), setBlocker(), setExpiry(), setHideName(), setReason(), setTarget(), setTimestamp(), wfGetDB(), and wfTimestamp().
Referenced by newFromRow(), and newLoad().
Block::insert | ( | $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 545 of file Block.php.
References $mId, $wgBlockDisablesLogin, and(), DB_MASTER, doRetroactiveAutoblock(), getBlocker(), getBlockRestrictionStore(), getDatabaseArray(), getSystemBlockType(), purgeExpired(), setId(), wfDebug(), and wfGetDB().
Block::isAutoblocking | ( | $x = null | ) |
null | bool | $x |
Definition at line 1159 of file Block.php.
References getType(), isAutoblocking(), and wfSetVar().
Referenced by __construct(), doAutoblock(), doRetroactiveAutoblock(), equals(), getDatabaseArray(), initFromRow(), isAutoblocking(), shouldTrackWithCookie(), and update().
Block::isCreateAccountBlocked | ( | $x = null | ) |
Get or set the flag indicating whether this block blocks the target from creating an account.
(Note that the flag may be overridden depending on global configs.)
null | bool | $x | Value to set (if null, just get the property value) |
Definition at line 1191 of file Block.php.
References wfSetVar().
Referenced by __construct(), appliesToPasswordReset(), appliesToRight(), doAutoblock(), equals(), getAutoblockUpdateArray(), getDatabaseArray(), and initFromRow().
Block::isEmailBlocked | ( | $x = null | ) |
Get or set the flag indicating whether this block blocks the target from sending emails.
(Note that the flag may be overridden depending on global configs.)
null | bool | $x | Value to set (if null, just get the property value) |
Definition at line 1204 of file Block.php.
References wfSetVar().
Referenced by __construct(), appliesToRight(), equals(), getDatabaseArray(), and initFromRow().
Block::isExpired | ( | ) |
Has the block expired?
Definition at line 956 of file Block.php.
References getExpiry(), wfDebug(), and wfTimestampNow().
Referenced by deleteIfExpired().
Block::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 1146 of file Block.php.
References $isHardblock, getType(), isHardblock(), true, and wfSetVar().
Referenced by __construct(), equals(), getDatabaseArray(), initFromRow(), and isHardblock().
Block::isSitewide | ( | $x = null | ) |
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).
null | bool | $x |
Definition at line 1178 of file Block.php.
References isSitewide(), and wfSetVar().
Referenced by __construct(), appliesToNamespace(), appliesToPage(), appliesToRight(), appliesToTitle(), appliesToUsertalk(), ApiBase\dieBlocked(), doAutoblock(), equals(), getAutoblockUpdateArray(), ApiQueryUserInfo\getBlockInfo(), getDatabaseArray(), getPermissionsError(), initFromRow(), isSitewide(), SpecialBlock\maybeAlterFormDefaults(), and prevents().
Block::isUsertalkEditAllowed | ( | $x = null | ) |
Get or set the flag indicating whether this block blocks the target from editing their own user talk page.
(Note that the flag may be overridden depending on global configs.)
null | bool | $x | Value to set (if null, just get the property value) |
Definition at line 1217 of file Block.php.
References wfSetVar().
Referenced by __construct(), appliesToUsertalk(), doAutoblock(), equals(), getAutoblockUpdateArray(), getDatabaseArray(), initFromRow(), and prevents().
Block::isValid | ( | ) |
Is the block address valid (i.e.
not a null string?)
Definition at line 973 of file Block.php.
References 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 812 of file Block.php.
References $cache, $line, $lines, and(), array(), DB_REPLICA, function, plain, wfDebug(), wfGetDB(), and wfMessage().
|
static |
Load a block from the block id.
int | $id | Block id to search for |
Definition at line 192 of file Block.php.
References $dbr, $res, DB_REPLICA, getQueryInfo(), newFromRow(), and wfGetDB().
Referenced by User\getBlockFromCookieValue(), newFromTarget(), ApiUnblockTest\setUp(), BlockTest\testCrappyCrossWikiBlocks(), BlockTest\testINewFromIDReturnsCorrectBlock(), and BlockTest\testRestrictionsFromDatabase().
|
static |
Create a new Block object from a database row.
stdClass | $row | Row from the ipblocks table |
Definition at line 505 of file Block.php.
References initFromRow().
Referenced by CleanupBlocks\execute(), getBlocksForIPList(), newFromID(), newLoad(), and BlockTest\testNewFromRow().
|
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 1403 of file Block.php.
References $target, $type, and(), list, newFromID(), and parseTarget().
Referenced by BlockTest\addBlockForUser(), SpecialContributions\contributionsSub(), doAutoblock(), ApiBlockTest\doBlock(), SpecialUnblock\execute(), ApiBlock\execute(), ApiUnblock\execute(), User\getBlockedStatus(), ApiUnblockTest\getBlockFromParams(), Article\getRobotPolicy(), DeletedContributionsPage\getSubTitle(), User\isBlockedFromCreateAccount(), SpecialBlock\maybeAlterFormDefaults(), SpecialBlock\processForm(), EditPage\showIntro(), Article\showMissingArticle(), User\spreadBlock(), BlockTest\testBlockedUserCanNotCreateAccount(), ApiBlockTest\testBlockWithoutRestrictions(), ApiBlockTest\testBlockWithRestrictions(), BlockTest\testCrappyCrossWikiBlocks(), ApiEditPageTest\testEditWhileBlocked(), BlockTest\testINewFromTargetReturnsCorrectBlock(), SpecialBlockTest\testMaybeAlterFormDefaults(), SpecialBlockTest\testMaybeAlterFormDefaultsPartial(), ApiMoveTest\testMoveWhileBlocked(), SpecialBlockTest\testProcessForm(), SpecialBlockTest\testProcessFormExisting(), SpecialBlockTest\testProcessFormRestrictions(), SpecialBlockTest\testProcessFormRestrictionsChange(), and BlockTest\testT31116NewFromTargetWithEmptyIp().
|
protected |
Load a block from the database which affects the already-set $this->target: 1) A block directly on the given user or IP 2) A rangeblock encompassing the given IP (smallest first) 3) An autoblock on the given IP.
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 324 of file Block.php.
References $res, $target, $type, and(), DB_MASTER, DB_REPLICA, getQueryInfo(), getRangeCond(), initFromRow(), list, LIST_OR, newFromRow(), parseTarget(), string, type, TYPE_IP, TYPE_RANGE, TYPE_USER, and wfGetDB().
|
static |
From an existing Block, get the target and the type of target.
Note that, except for null, it is always safe to treat the target as a string; for User objects this will return User::__toString() which in turn gives User::getName().
string | int | User | null | $target |
Definition at line 1625 of file Block.php.
References $target, and(), User\getName(), User\newFromName(), null, TYPE_AUTO, TYPE_IP, TYPE_RANGE, and TYPE_USER.
Referenced by BlockListPager\formatValue(), SpecialBlockList\getBlockListPager(), SpecialBlock\getTargetAndType(), newFromTarget(), newLoad(), SpecialBlock\setParameter(), and setTarget().
Block::prevents | ( | $action, | |
$x = null ) |
Get/set whether the Block prevents a given action.
string | $action | Action to check |
bool | null | $x | Value for set, or null to just get value |
Definition at line 1277 of file Block.php.
References $res, and(), User\isAllowed(), isSitewide(), isUsertalkEditAllowed(), and wfSetVar().
|
static |
Purge expired blocks from the ipblocks table.
Definition at line 1359 of file Block.php.
References $fname, Wikimedia\Rdbms\IDatabase\addQuotes(), DB_MASTER, Wikimedia\Rdbms\IDatabase\delete(), Wikimedia\Rdbms\IDatabase\selectFieldValues(), Wikimedia\Rdbms\IDatabase\timestamp(), wfGetDB(), and wfReadOnly().
Referenced by insert().
|
static |
Return the list of ipblocks fields that should be selected to create a new block.
Definition at line 216 of file Block.php.
References $wgActorTableSchemaMigrationStage, SCHEMA_COMPAT_READ_NEW, and wfDeprecated().
Block::setBlocker | ( | $user | ) |
Set the user who implemented (or will implement) this block.
Definition at line 1769 of file Block.php.
References $user, and(), User\isUsableName(), and User\newFromName().
Referenced by __construct(), and initFromRow().
Block::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 1791 of file Block.php.
References $expiryTime, and(), false, getCookieValue(), getExpiry(), WebResponse\setCookie(), and wfTimestamp().
Block::setExpiry | ( | $expiry | ) |
Set the block expiry time.
string | $expiry |
Definition at line 1725 of file Block.php.
Referenced by __construct(), initFromRow(), and updateTimestamp().
Block::setHideName | ( | $hideName | ) |
Set whether ths block hides the target's username.
bool | $hideName | The block hides the username |
Definition at line 1118 of file Block.php.
References and().
Referenced by __construct(), and initFromRow().
|
private |
Set the block ID.
int | $blockId |
Definition at line 1070 of file Block.php.
References and(), and getBlockRestrictionStore().
Referenced by insert().
Block::setReason | ( | $reason | ) |
Set the reason for creating the block.
string | $reason |
Definition at line 1098 of file Block.php.
Referenced by __construct(), and initFromRow().
Block::setRestrictions | ( | array | $restrictions | ) |
Set Restrictions.
Restriction[] | $restrictions |
Definition at line 1963 of file Block.php.
References $restrictions, and and().
Block::setTarget | ( | $target | ) |
Set the target for this block, and update $this->type accordingly.
mixed | $target |
Definition at line 1753 of file Block.php.
References list, parseTarget(), and type.
Referenced by __construct(), and initFromRow().
Block::setTimestamp | ( | $timestamp | ) |
Set the timestamp indicating when the block was created.
string | $timestamp |
Definition at line 1745 of file Block.php.
Referenced by __construct(), initFromRow(), and updateTimestamp().
Block::shouldTrackWithCookie | ( | $isIpUser | ) |
Check if the block should be tracked with a cookie.
bool | $isIpUser | The user is logged out |
Definition at line 2138 of file Block.php.
References getType(), isAutoblocking(), TYPE_IP, TYPE_RANGE, and TYPE_USER.
Block::update | ( | ) |
Update a block in the DB with new parameters.
The ID field needs to be loaded first.
Definition at line 622 of file Block.php.
References $mId, $result, $success, and(), DB_MASTER, doRetroactiveAutoblock(), getAutoblockUpdateArray(), getBlockRestrictionStore(), getDatabaseArray(), getId(), isAutoblocking(), wfDebug(), and wfGetDB().
Block::updateTimestamp | ( | ) |
Update the timestamp on autoblocks.
Definition at line 981 of file Block.php.
References DB_MASTER, getTimestamp(), setExpiry(), setTimestamp(), wfGetDB(), and wfTimestamp().
|
private |
Definition at line 78 of file Block.php.
Referenced by getBlocker(), and getBlockErrorParams().
|
private |
Hack for foreign blocking (CentralAuth)
Definition at line 69 of file Block.php.
Referenced by getDatabaseArray().
|
private |
Definition at line 81 of file Block.php.
Referenced by isHardblock().
string Block::$mExpiry |
Definition at line 42 of file Block.php.
Referenced by getExpiry().
bool Block::$mHideName |
Definition at line 45 of file Block.php.
Referenced by getHideName().
|
private |
int Block::$mParentBlockId |
Definition at line 48 of file Block.php.
Referenced by getDatabaseArray().
string Block::$mReason |
Definition at line 33 of file Block.php.
Referenced by getReason().
string Block::$mTimestamp |
Definition at line 36 of file Block.php.
Referenced by getTimestamp().
|
private |
Definition at line 93 of file Block.php.
Referenced by findRestriction(), getRestrictions(), and setRestrictions().
|
private |
Definition at line 87 of file Block.php.
Referenced by getBlockErrorParams(), and getSystemBlockType().
|
private |
Definition at line 66 of file Block.php.
Referenced by defaultRetroactiveAutoblock(), getTarget(), newFromTarget(), newLoad(), and parseTarget().
|
private |
Block::TYPE_ constant.
After the block has been loaded from the database, this can only be USER, IP or RANGE.
Definition at line 75 of file Block.php.
Referenced by findRestriction(), getType(), newFromTarget(), and newLoad().
const Block::TYPE_AUTO = 4 |
Definition at line 99 of file Block.php.
Referenced by SpecialContributions\contributionsSub(), ApiBase\dieBlocked(), SpecialUnblock\execute(), ApiUnblock\execute(), SpecialBlockList\getBlockListPager(), DeletedContributionsPage\getSubTitle(), getType(), SpecialBlock\maybeAlterFormDefaults(), parseTarget(), EditPage\showIntro(), and Article\showMissingArticle().
const Block::TYPE_ID = 5 |
Definition at line 100 of file Block.php.
Referenced by SpecialUnblock\execute(), and SpecialBlockList\getBlockListPager().
const Block::TYPE_IP = 2 |
Definition at line 97 of file Block.php.
Referenced by BlockTest\addXffBlocks(), SpecialUnblock\execute(), BlockListPager\formatValue(), User\getBlockFromCookieValue(), SpecialBlockList\getBlockListPager(), getRangeEnd(), getRangeStart(), newLoad(), parseTarget(), SpecialBlock\processForm(), shouldTrackWithCookie(), and SpecialBlock\validateTarget().
const Block::TYPE_RANGE = 3 |
Definition at line 98 of file Block.php.
Referenced by BlockTest\addXffBlocks(), MediaWiki\Auth\AuthManager\checkAccountCreatePermissions(), SpecialContributions\contributionsSub(), SpecialUnblock\execute(), BlockListPager\formatValue(), User\getBlockFromCookieValue(), SpecialBlockList\getBlockListPager(), getRangeEnd(), getRangeStart(), DeletedContributionsPage\getSubTitle(), SpecialBlock\maybeAlterFormDefaults(), newLoad(), parseTarget(), SpecialBlock\processForm(), shouldTrackWithCookie(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProvider\testUserForCreation(), and SpecialBlock\validateTarget().
const Block::TYPE_USER = 1 |
Definition at line 96 of file Block.php.
Referenced by SpecialBlock\blockLogFlags(), SpecialUnblock\execute(), ApiBlock\execute(), BlockListPager\formatValue(), User\getBlockFromCookieValue(), SpecialBlockList\getBlockListPager(), getRangeEnd(), getRangeStart(), newLoad(), parseTarget(), SpecialBlock\processForm(), shouldTrackWithCookie(), UserTest\testAutoblockCookieInfiniteExpiry(), UserTest\testAutoblockCookies(), UserTest\testAutoblockCookiesDisabled(), and SpecialBlock\validateTarget().