MediaWiki REL1_37
MediaWiki\Block\DatabaseBlockStore Class Reference
Collaboration diagram for MediaWiki\Block\DatabaseBlockStore:

Public Member Functions

 __construct (ServiceOptions $options, LoggerInterface $logger, ActorStoreFactory $actorStoreFactory, BlockRestrictionStore $blockRestrictionStore, CommentStore $commentStore, HookContainer $hookContainer, ILoadBalancer $loadBalancer, ReadOnlyMode $readOnlyMode, UserFactory $userFactory)
 
 deleteBlock (DatabaseBlock $block)
 Delete a DatabaseBlock from the database.
 
 insertBlock (DatabaseBlock $block, IDatabase $database=null)
 Insert a block into the block table.
 
 purgeExpiredBlocks ()
 Delete expired blocks from the ipblocks table.
 
 updateBlock (DatabaseBlock $block)
 Update a block in the DB with new parameters.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Member Functions

 checkDatabaseDomain (?IDatabase $db, $expectedWiki)
 Throws an exception if the given database connection does not match the given wiki ID.
 
 doRetroactiveAutoblock (DatabaseBlock $block)
 Handles retroactively autoblocking the last IP used by the user (if it is a user) blocked by an auto block.
 
 getArrayForAutoblockUpdate (DatabaseBlock $block)
 Get an array suitable for autoblock updates.
 
 getArrayForDatabaseBlock (DatabaseBlock $block, IDatabase $dbw)
 Get an array suitable for passing to $dbw->insert() or $dbw->update()
 
 performRetroactiveAutoblock (DatabaseBlock $block)
 Actually retroactively autoblocks the last IP used by the user (if it is a user) blocked by this block.
 

Private Attributes

ActorStoreFactory $actorStoreFactory
 
BlockRestrictionStore $blockRestrictionStore
 
CommentStore $commentStore
 
HookRunner $hookRunner
 
ILoadBalancer $loadBalancer
 
LoggerInterface $logger
 
ServiceOptions $options
 
ReadOnlyMode $readOnlyMode
 
UserFactory $userFactory
 

Detailed Description

Since
1.36
Author
DannyS712

Definition at line 47 of file DatabaseBlockStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\DatabaseBlockStore::__construct ( ServiceOptions  $options,
LoggerInterface  $logger,
ActorStoreFactory  $actorStoreFactory,
BlockRestrictionStore  $blockRestrictionStore,
CommentStore  $commentStore,
HookContainer  $hookContainer,
ILoadBalancer  $loadBalancer,
ReadOnlyMode  $readOnlyMode,
UserFactory  $userFactory 
)

Member Function Documentation

◆ checkDatabaseDomain()

MediaWiki\Block\DatabaseBlockStore::checkDatabaseDomain ( ?IDatabase  $db,
  $expectedWiki 
)
private

Throws an exception if the given database connection does not match the given wiki ID.

Parameters
?IDatabase$db
string | false$expectedWiki

Definition at line 157 of file DatabaseBlockStore.php.

References Wikimedia\Rdbms\IDatabase\getDomainID().

Referenced by MediaWiki\Block\DatabaseBlockStore\insertBlock().

◆ deleteBlock()

MediaWiki\Block\DatabaseBlockStore::deleteBlock ( DatabaseBlock  $block)

Delete a DatabaseBlock from the database.

Parameters
DatabaseBlock$block
Returns
bool whether it was deleted
Exceptions
MWException

Definition at line 345 of file DatabaseBlockStore.php.

◆ doRetroactiveAutoblock()

MediaWiki\Block\DatabaseBlockStore::doRetroactiveAutoblock ( DatabaseBlock  $block)
private

Handles retroactively autoblocking the last IP used by the user (if it is a user) blocked by an auto block.

Parameters
DatabaseBlock$block
Returns
array IDs of retroactive autoblocks made

Definition at line 470 of file DatabaseBlockStore.php.

References MediaWiki\Block\AbstractBlock\getTargetName().

Referenced by MediaWiki\Block\DatabaseBlockStore\insertBlock(), and MediaWiki\Block\DatabaseBlockStore\updateBlock().

◆ getArrayForAutoblockUpdate()

MediaWiki\Block\DatabaseBlockStore::getArrayForAutoblockUpdate ( DatabaseBlock  $block)
private

Get an array suitable for autoblock updates.

Parameters
DatabaseBlock$block
Returns
array

Definition at line 437 of file DatabaseBlockStore.php.

Referenced by MediaWiki\Block\DatabaseBlockStore\updateBlock().

◆ getArrayForDatabaseBlock()

MediaWiki\Block\DatabaseBlockStore::getArrayForDatabaseBlock ( DatabaseBlock  $block,
IDatabase  $dbw 
)
private

Get an array suitable for passing to $dbw->insert() or $dbw->update()

Parameters
DatabaseBlock$block
IDatabase$dbwDatabase to use if not the same as the one in the load balancer. Must connect to the wiki identified by $block->getBlocker->getWikiId().
Returns
array

Definition at line 384 of file DatabaseBlockStore.php.

References MediaWiki\Block\AbstractBlock\getTargetUserIdentity().

Referenced by MediaWiki\Block\DatabaseBlockStore\insertBlock(), and MediaWiki\Block\DatabaseBlockStore\updateBlock().

◆ insertBlock()

MediaWiki\Block\DatabaseBlockStore::insertBlock ( DatabaseBlock  $block,
IDatabase  $database = null 
)

Insert a block into the block table.

Will fail if there is a conflicting block (same name and options) already in the database.

Parameters
DatabaseBlock$block
IDatabase | null$databaseDatabase to use if not the same as the one in the load balancer. Must connect to the wiki identified by $block->getBlocker->getWikiId().
Returns
bool|array False on failure, assoc array on success: ('id' => block ID, 'autoIds' => array of autoblock IDs)
Exceptions
MWException

Definition at line 186 of file DatabaseBlockStore.php.

References MediaWiki\Block\DatabaseBlockStore\checkDatabaseDomain(), DB_PRIMARY, MediaWiki\Block\DatabaseBlockStore\doRetroactiveAutoblock(), MediaWiki\Block\DatabaseBlockStore\getArrayForDatabaseBlock(), MediaWiki\Block\DatabaseBlock\getBlocker(), MediaWiki\Block\DatabaseBlock\getId(), MediaWiki\Block\DatabaseBlock\getRawRestrictions(), MediaWiki\Block\AbstractBlock\getTargetUserIdentity(), MediaWiki\Block\AbstractBlock\getTimestamp(), MediaWiki\Block\DatabaseBlockStore\purgeExpiredBlocks(), and MediaWiki\Block\DatabaseBlock\setId().

◆ performRetroactiveAutoblock()

MediaWiki\Block\DatabaseBlockStore::performRetroactiveAutoblock ( DatabaseBlock  $block)
private

Actually retroactively autoblocks the last IP used by the user (if it is a user) blocked by this block.

This will use the recentchanges table.

Parameters
DatabaseBlock$block
Returns
array

Definition at line 501 of file DatabaseBlockStore.php.

◆ purgeExpiredBlocks()

MediaWiki\Block\DatabaseBlockStore::purgeExpiredBlocks ( )

◆ updateBlock()

MediaWiki\Block\DatabaseBlockStore::updateBlock ( DatabaseBlock  $block)

Member Data Documentation

◆ $actorStoreFactory

ActorStoreFactory MediaWiki\Block\DatabaseBlockStore::$actorStoreFactory
private

◆ $blockRestrictionStore

BlockRestrictionStore MediaWiki\Block\DatabaseBlockStore::$blockRestrictionStore
private

◆ $commentStore

CommentStore MediaWiki\Block\DatabaseBlockStore::$commentStore
private

◆ $hookRunner

HookRunner MediaWiki\Block\DatabaseBlockStore::$hookRunner
private

Definition at line 73 of file DatabaseBlockStore.php.

◆ $loadBalancer

ILoadBalancer MediaWiki\Block\DatabaseBlockStore::$loadBalancer
private

◆ $logger

LoggerInterface MediaWiki\Block\DatabaseBlockStore::$logger
private

◆ $options

ServiceOptions MediaWiki\Block\DatabaseBlockStore::$options
private

◆ $readOnlyMode

ReadOnlyMode MediaWiki\Block\DatabaseBlockStore::$readOnlyMode
private

◆ $userFactory

UserFactory MediaWiki\Block\DatabaseBlockStore::$userFactory
private

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Block\DatabaseBlockStore::CONSTRUCTOR_OPTIONS
Initial value:
= [
'PutIPinRC',
'BlockDisablesLogin',
]
Access: internal
For use by ServiceWiring

Definition at line 55 of file DatabaseBlockStore.php.


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