|
MediaWiki master
|
Public Member Functions | |
| __construct (ServiceOptions $options, LoggerInterface $logger, ActorStoreFactory $actorStoreFactory, BlockRestrictionStore $blockRestrictionStore, CommentStore $commentStore, HookContainer $hookContainer, IConnectionProvider $dbProvider, ReadOnlyMode $readOnlyMode, UserFactory $userFactory, TempUserConfig $tempUserConfig, BlockTargetFactory $blockTargetFactory, AutoblockExemptionList $autoblockExemptionList, SessionManagerInterface $sessionManager, ILockManager $lockManager, string|false $wikiId=DatabaseBlock::LOCAL) | |
Public Attributes | |
| const | AUTO_ALL = 'all' |
| Load all autoblocks. | |
| const | AUTO_NONE = 'none' |
| Do not load autoblocks. | |
| const | AUTO_SPECIFIED = 'specified' |
| Load only autoblocks specified by ID. | |
| const | CONSTRUCTOR_OPTIONS |
| const | DELETED_DEFERRED = 4 |
| The block is deferred, see DatabaseBlock::isDeferred(). | |
| const | DELETED_HIDE_BLOCK = 2 |
| The block is hidden, but the target user name is not. | |
| const | DELETED_HIDE_USER = 1 |
| Values for the bl_deleted field. | |
| const | DELETED_VISIBILITY_MASK = 3 |
| Mask to extract the visibility value from bl_deleted. | |
Database read methods | |
| newFromID ( $id, $fromPrimary=false, $includeExpired=false, $includeDeferred=false) | |
| Load a block from the block ID. | |
| getQueryInfo () | |
| Return the tables, fields, and join conditions to be selected to create a new block object. | |
| getConditionForRanges (array $ranges) | |
| Get a set of SQL conditions which select range blocks encompassing the given ranges. | |
| getRangeCond ( $start, $end) | |
| Get a set of SQL conditions which select range blocks encompassing a given range. | |
| newFromRow (IReadableDatabase $db, $row) | |
| Create a new DatabaseBlock object from a database row. | |
| newFromTarget ( $specificTarget, $vagueTarget=null, $fromPrimary=false, $auto=self::AUTO_ALL, $includeDeferred=false) | |
| Given a target and the target's type, get an existing block object if possible. | |
| newListFromTarget ( $specificTarget, $vagueTarget=null, $fromPrimary=false, $auto=self::AUTO_ALL, $includeDeferred=false) | |
| This is similar to DatabaseBlockStore::newFromTarget, but it returns all the relevant blocks. | |
| newListFromIPs (array $addresses, $applySoftBlocks, $fromPrimary=false) | |
| Get all blocks that match any IP from an array of IP addresses. | |
| newListFromConds ( $conds, $fromPrimary=false, $includeExpired=false, $includeDeferred=false) | |
| Construct an array of blocks from database conditions. | |
Database write methods | |
| newUnsaved (array $options) | |
| Create a DatabaseBlock representing an unsaved block. | |
| purgeExpiredBlocks () | |
| Delete expired blocks from the block table. | |
| deleteBlocksMatchingConds (array $conds, $limit=null) | |
| Delete all blocks matching the given conditions. | |
| insertBlock (DatabaseBlock $block, $expectedTargetCount=0) | |
| Insert a block into the block table. | |
| insertBlockWithParams (array $params) | |
| Create a block with an array of parameters and immediately insert it. | |
| updateBlock (DatabaseBlock $block) | |
| Update a block in the DB with new parameters. | |
| updateTarget (DatabaseBlock $block, $newTarget) | |
| Update the target in the specified object and in the database. | |
| deleteBlock (DatabaseBlock $block) | |
| Delete a DatabaseBlock from the database. | |
| doAutoblock (DatabaseBlock $parentBlock, $autoblockIP) | |
| Autoblocks the given IP, referring to the specified block. | |
| updateTimestamp (DatabaseBlock $block) | |
| Update the timestamp on autoblocks. | |
| getAutoblockExpiry ( $timestamp, ?string $parentExpiry=null) | |
| Get the expiry timestamp for an autoblock created at the given time. | |
Definition at line 47 of file DatabaseBlockStore.php.
| MediaWiki\Block\DatabaseBlockStore::__construct | ( | ServiceOptions | $options, |
| LoggerInterface | $logger, | ||
| ActorStoreFactory | $actorStoreFactory, | ||
| BlockRestrictionStore | $blockRestrictionStore, | ||
| CommentStore | $commentStore, | ||
| HookContainer | $hookContainer, | ||
| IConnectionProvider | $dbProvider, | ||
| ReadOnlyMode | $readOnlyMode, | ||
| UserFactory | $userFactory, | ||
| TempUserConfig | $tempUserConfig, | ||
| BlockTargetFactory | $blockTargetFactory, | ||
| AutoblockExemptionList | $autoblockExemptionList, | ||
| SessionManagerInterface | $sessionManager, | ||
| ILockManager | $lockManager, | ||
| string|false | $wikiId = DatabaseBlock::LOCAL ) |
Definition at line 98 of file DatabaseBlockStore.php.
References MediaWiki\DAO\WikiAwareEntity\LOCAL.
| MediaWiki\Block\DatabaseBlockStore::deleteBlock | ( | DatabaseBlock | $block | ) |
Delete a DatabaseBlock from the database.
| DatabaseBlock | $block |
Definition at line 1343 of file DatabaseBlockStore.php.
References if.
| MediaWiki\Block\DatabaseBlockStore::deleteBlocksMatchingConds | ( | array | $conds, |
| $limit = null ) |
Delete all blocks matching the given conditions.
| array | $conds | An associative array mapping the field name to the matched value. |
| int | null | $limit | The maximum number of blocks to delete |
Definition at line 735 of file DatabaseBlockStore.php.
Referenced by updateBlock().
| MediaWiki\Block\DatabaseBlockStore::doAutoblock | ( | DatabaseBlock | $parentBlock, |
| $autoblockIP ) |
Autoblocks the given IP, referring to the specified block.
| DatabaseBlock | $parentBlock | |
| string | $autoblockIP | The IP to autoblock. |
Definition at line 1573 of file DatabaseBlockStore.php.
References MediaWiki\DAO\WikiAwareEntity\assertWiki(), getAutoblockExpiry(), MediaWiki\Block\DatabaseBlock\getBlocker(), MediaWiki\Block\AbstractBlock\getExpiry(), MediaWiki\Block\AbstractBlock\getHideBlock(), MediaWiki\Block\AbstractBlock\getHideName(), MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\DatabaseBlock\getRestrictions(), insertBlock(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\AbstractBlock\isCreateAccountBlocked(), MediaWiki\Block\DatabaseBlock\isDeferred(), MediaWiki\Block\AbstractBlock\isSitewide(), MediaWiki\Block\AbstractBlock\isUsertalkEditAllowed(), MediaWiki\Block\Block\TYPE_AUTO, updateTimestamp(), and wfTimestampNow().
| MediaWiki\Block\DatabaseBlockStore::getAutoblockExpiry | ( | $timestamp, | |
| ?string | $parentExpiry = null ) |
Get the expiry timestamp for an autoblock created at the given time.
If the parent block expiry is specified, the return value will be earlier than or equal to the parent block expiry.
| string | int | $timestamp | |
| string | null | $parentExpiry |
Definition at line 1705 of file DatabaseBlockStore.php.
References MediaWiki\MainConfigNames\AutoblockExpiry, and wfTimestamp().
Referenced by doAutoblock(), and updateTimestamp().
| MediaWiki\Block\DatabaseBlockStore::getConditionForRanges | ( | array | $ranges | ) |
Get a set of SQL conditions which select range blocks encompassing the given ranges.
For each range that is really a single IP (start=end), it will also select single IP blocks with that IP.
| string[][] | $ranges | List of elements with [ start, end ], where start and end are hexadecimal IP representation, and end can be null to use end = start. |
Definition at line 382 of file DatabaseBlockStore.php.
Referenced by getRangeCond(), and newListFromIPs().
| MediaWiki\Block\DatabaseBlockStore::getQueryInfo | ( | ) |
Return the tables, fields, and join conditions to be selected to create a new block object.
Definition at line 170 of file DatabaseBlockStore.php.
Referenced by newListFromConds(), and newListFromIPs().
| MediaWiki\Block\DatabaseBlockStore::getRangeCond | ( | $start, | |
| $end ) |
Get a set of SQL conditions which select range blocks encompassing a given range.
If the given range is a single IP with start=end, it will also select single IP blocks with that IP.
| string | $start | Hexadecimal IP representation |
| string | null | $end | Hexadecimal IP representation, or null to use $start = $end |
Definition at line 426 of file DatabaseBlockStore.php.
References getConditionForRanges().
| MediaWiki\Block\DatabaseBlockStore::insertBlock | ( | DatabaseBlock | $block, |
| $expectedTargetCount = 0 ) |
Insert a block into the block table.
Will fail if there is a conflicting block (same name and options) already in the database.
| DatabaseBlock | $block | |
| int | null | $expectedTargetCount | The expected number of existing blocks on the specified target. If this is zero but there is an existing block, the insertion will fail. |
Definition at line 889 of file DatabaseBlockStore.php.
References MediaWiki\DAO\WikiAwareEntity\assertWiki(), MediaWiki\MainConfigNames\BlockDisablesLogin, MediaWiki\Block\DatabaseBlock\getBlocker(), MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\AbstractBlock\getTargetUserIdentity(), MediaWiki\Block\AbstractBlock\getTimestamp(), MediaWiki\Block\DatabaseBlock\isDeferred(), and purgeExpiredBlocks().
Referenced by doAutoblock(), and insertBlockWithParams().
| MediaWiki\Block\DatabaseBlockStore::insertBlockWithParams | ( | array | $params | ) |
Create a block with an array of parameters and immediately insert it.
Throw an exception on failure. This is a convenience method for testing.
Duplicate blocks for a given target are allowed by default.
| array | $params | Parameters for newUnsaved(), and also:
|
Definition at line 970 of file DatabaseBlockStore.php.
References insertBlock(), and newUnsaved().
| MediaWiki\Block\DatabaseBlockStore::newFromID | ( | $id, | |
| $fromPrimary = false, | |||
| $includeExpired = false, | |||
| $includeDeferred = false ) |
Load a block from the block ID.
| int | $id | ID to search for |
| bool | $fromPrimary | Whether to use the DB_PRIMARY database (since 1.44) |
| bool | $includeExpired | Whether to include expired blocks (since 1.44) |
| bool | $includeDeferred | Whether to include deferred blocks (since 1.48) |
Definition at line 149 of file DatabaseBlockStore.php.
References newListFromConds().
Referenced by newListFromTarget().
| MediaWiki\Block\DatabaseBlockStore::newFromRow | ( | IReadableDatabase | $db, |
| $row ) |
Create a new DatabaseBlock object from a database row.
| IReadableDatabase | $db | The database you got the row from |
| stdClass | $row | Row from the block table |
Definition at line 456 of file DatabaseBlockStore.php.
References Wikimedia\Rdbms\Platform\ISQLPlatform\decodeExpiry().
Referenced by newListFromConds(), and newListFromIPs().
| MediaWiki\Block\DatabaseBlockStore::newFromTarget | ( | $specificTarget, | |
| $vagueTarget = null, | |||
| $fromPrimary = false, | |||
| $auto = self::AUTO_ALL, | |||
| $includeDeferred = false ) |
Given a target and the target's type, get an existing block object if possible.
| BlockTarget | string | UserIdentity | int | null | $specificTarget | A block target, which may be one of several types:
|
Calling this with a user, IP address or range will not select autoblocks, and will only select a block where the targets match exactly (so looking for blocks on 1.2.3.4 will not select 1.2.0.0/16 or even 1.2.3.4/32).
| BlockTarget | 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 |
| string | $auto | Since 1.44. One of the self::AUTO_* constants:
|
| bool | $includeDeferred | Whether to include deferred blocks (since 1.48) |
Definition at line 514 of file DatabaseBlockStore.php.
References newListFromTarget().
| MediaWiki\Block\DatabaseBlockStore::newListFromConds | ( | $conds, | |
| $fromPrimary = false, | |||
| $includeExpired = false, | |||
| $includeDeferred = false ) |
Construct an array of blocks from database conditions.
| array | $conds | Query conditions, given as an associative array mapping field names to values. |
| bool | $fromPrimary | |
| bool | $includeExpired | |
| bool | $includeDeferred | Whether to include deferred blocks (since 1.48) |
Definition at line 627 of file DatabaseBlockStore.php.
References getQueryInfo(), and newFromRow().
Referenced by newFromID().
| MediaWiki\Block\DatabaseBlockStore::newListFromIPs | ( | array | $addresses, |
| $applySoftBlocks, | |||
| $fromPrimary = false ) |
Get all blocks that match any IP from an array of IP addresses.
| string[] | $addresses | Validated list of IP addresses |
| 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 576 of file DatabaseBlockStore.php.
References getConditionForRanges(), getQueryInfo(), LIST_OR, and newFromRow().
| MediaWiki\Block\DatabaseBlockStore::newListFromTarget | ( | $specificTarget, | |
| $vagueTarget = null, | |||
| $fromPrimary = false, | |||
| $auto = self::AUTO_ALL, | |||
| $includeDeferred = false ) |
This is similar to DatabaseBlockStore::newFromTarget, but it returns all the relevant blocks.
| BlockTarget | string | UserIdentity | int | null | $specificTarget | |
| BlockTarget | string | UserIdentity | int | null | $vagueTarget | |
| bool | $fromPrimary | |
| string | $auto | Since 1.44. One of the self::AUTO_* constants:
|
| bool | $includeDeferred | Whether to include deferred blocks (since 1.48) |
Definition at line 539 of file DatabaseBlockStore.php.
References newFromID().
Referenced by MediaWiki\Logging\LogEventsList\getBlockLogWarningBox(), and newFromTarget().
| MediaWiki\Block\DatabaseBlockStore::newUnsaved | ( | array | $options | ) |
Create a DatabaseBlock representing an unsaved block.
Pass the returned object to insertBlock().
| array | $options | Options as documented in DatabaseBlock and AbstractBlock, and additionally:
|
Definition at line 679 of file DatabaseBlockStore.php.
References if.
Referenced by insertBlockWithParams().
| MediaWiki\Block\DatabaseBlockStore::purgeExpiredBlocks | ( | ) |
Delete expired blocks from the block table.
Definition at line 702 of file DatabaseBlockStore.php.
References Wikimedia\Rdbms\IReadableDatabase\expr(), Wikimedia\Rdbms\IReadableDatabase\newSelectQueryBuilder(), Wikimedia\Rdbms\Platform\ISQLPlatform\timestamp(), and MediaWiki\MainConfigNames\UpdateRowsPerQuery.
Referenced by insertBlock().
| MediaWiki\Block\DatabaseBlockStore::updateBlock | ( | DatabaseBlock | $block | ) |
Update a block in the DB with new parameters.
The ID field needs to be loaded first. The target must stay the same.
TODO: remove the possibility of false return. The cases where this happens are exotic enough that they should just be exceptions.
| DatabaseBlock | $block |
Definition at line 1215 of file DatabaseBlockStore.php.
References MediaWiki\DAO\WikiAwareEntity\assertWiki(), deleteBlocksMatchingConds(), MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\DatabaseBlock\getRawRestrictions(), MediaWiki\Block\AbstractBlock\getTimestamp(), MediaWiki\Block\DatabaseBlock\isAutoblocking(), MediaWiki\Block\AbstractBlock\setTimestamp(), and wfTimestamp().
| MediaWiki\Block\DatabaseBlockStore::updateTarget | ( | DatabaseBlock | $block, |
| $newTarget ) |
Update the target in the specified object and in the database.
The block ID must be set.
This is an unusual operation, currently used only by the UserMerge extension.
| DatabaseBlock | $block | |
| BlockTarget | UserIdentity | string | $newTarget |
Definition at line 1296 of file DatabaseBlockStore.php.
References MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\AbstractBlock\getTarget(), and MediaWiki\Block\AbstractBlock\setTarget().
| MediaWiki\Block\DatabaseBlockStore::updateTimestamp | ( | DatabaseBlock | $block | ) |
Update the timestamp on autoblocks.
| DatabaseBlock | $block |
Definition at line 1670 of file DatabaseBlockStore.php.
References MediaWiki\DAO\WikiAwareEntity\assertWiki(), getAutoblockExpiry(), MediaWiki\Block\AbstractBlock\getExpiry(), MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\AbstractBlock\getTimestamp(), MediaWiki\Block\DatabaseBlock\getType(), MediaWiki\Block\AbstractBlock\setExpiry(), MediaWiki\Block\AbstractBlock\setTimestamp(), MediaWiki\Block\Block\TYPE_AUTO, and wfTimestamp().
Referenced by doAutoblock().
| const MediaWiki\Block\DatabaseBlockStore::AUTO_ALL = 'all' |
Load all autoblocks.
Definition at line 49 of file DatabaseBlockStore.php.
| const MediaWiki\Block\DatabaseBlockStore::AUTO_NONE = 'none' |
Do not load autoblocks.
Definition at line 53 of file DatabaseBlockStore.php.
| const MediaWiki\Block\DatabaseBlockStore::AUTO_SPECIFIED = 'specified' |
Load only autoblocks specified by ID.
Definition at line 51 of file DatabaseBlockStore.php.
| const MediaWiki\Block\DatabaseBlockStore::CONSTRUCTOR_OPTIONS |
Definition at line 73 of file DatabaseBlockStore.php.
| const MediaWiki\Block\DatabaseBlockStore::DELETED_DEFERRED = 4 |
The block is deferred, see DatabaseBlock::isDeferred().
Definition at line 68 of file DatabaseBlockStore.php.
| const MediaWiki\Block\DatabaseBlockStore::DELETED_HIDE_BLOCK = 2 |
The block is hidden, but the target user name is not.
Definition at line 64 of file DatabaseBlockStore.php.
| const MediaWiki\Block\DatabaseBlockStore::DELETED_HIDE_USER = 1 |
Values for the bl_deleted field.
The low two bits hold the visibility of the block: either 0 (visible), DELETED_HIDE_USER or DELETED_HIDE_BLOCK. These two values are mutually exclusive. DELETED_DEFERRED is a flag that can be combined with any of the visibility values. The block hides the target user name (and the block itself)
Definition at line 62 of file DatabaseBlockStore.php.
| const MediaWiki\Block\DatabaseBlockStore::DELETED_VISIBILITY_MASK = 3 |
Mask to extract the visibility value from bl_deleted.
Definition at line 66 of file DatabaseBlockStore.php.