MediaWiki master
DatabaseBlockStoreFactory.php
Go to the documentation of this file.
1<?php
6
7namespace MediaWiki\Block;
8
9use MediaWiki\CommentStore\CommentStore;
10use MediaWiki\Config\ServiceOptions;
11use MediaWiki\HookContainer\HookContainer;
12use MediaWiki\Session\SessionManagerInterface;
13use MediaWiki\User\ActorStoreFactory;
14use MediaWiki\User\TempUser\TempUserConfig;
15use MediaWiki\User\UserFactory;
16use MediaWiki\WikiMap\WikiMap;
17use Psr\Log\LoggerInterface;
18use Wikimedia\LockManager\ILockManager;
19use Wikimedia\Rdbms\LBFactory;
20use Wikimedia\Rdbms\ReadOnlyMode;
21
32
33 private ServiceOptions $options;
34 private LoggerInterface $logger;
35 private ActorStoreFactory $actorStoreFactory;
36 private BlockRestrictionStoreFactory $blockRestrictionStoreFactory;
37 private CommentStore $commentStore;
38 private HookContainer $hookContainer;
39 private LBFactory $loadBalancerFactory;
40 private ReadOnlyMode $readOnlyMode;
41 private UserFactory $userFactory;
42 private TempUserConfig $tempUserConfig;
43 private CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory;
44 private AutoblockExemptionList $autoblockExemptionList;
45 private SessionManagerInterface $sessionManager;
46
48 private array $storeCache = [];
49 private ILockManager $lockManager;
50
51 public function __construct(
52 ServiceOptions $options,
53 LoggerInterface $logger,
54 ActorStoreFactory $actorStoreFactory,
55 BlockRestrictionStoreFactory $blockRestrictionStoreFactory,
56 CommentStore $commentStore,
57 HookContainer $hookContainer,
58 LBFactory $loadBalancerFactory,
59 ReadOnlyMode $readOnlyMode,
60 UserFactory $userFactory,
61 TempUserConfig $tempUserConfig,
62 CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory,
63 AutoblockExemptionList $autoblockExemptionList,
64 SessionManagerInterface $sessionManager,
65 ILockManager $lockManager
66 ) {
67 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
68
69 $this->options = $options;
70 $this->logger = $logger;
71 $this->actorStoreFactory = $actorStoreFactory;
72 $this->blockRestrictionStoreFactory = $blockRestrictionStoreFactory;
73 $this->commentStore = $commentStore;
74 $this->hookContainer = $hookContainer;
75 $this->loadBalancerFactory = $loadBalancerFactory;
76 $this->readOnlyMode = $readOnlyMode;
77 $this->userFactory = $userFactory;
78 $this->tempUserConfig = $tempUserConfig;
79 $this->crossWikiBlockTargetFactory = $crossWikiBlockTargetFactory;
80 $this->autoblockExemptionList = $autoblockExemptionList;
81 $this->sessionManager = $sessionManager;
82 $this->lockManager = $lockManager;
83 }
84
85 public function getDatabaseBlockStore( string|false $wikiId = DatabaseBlock::LOCAL ): DatabaseBlockStore {
86 if (
87 is_string( $wikiId ) &&
88 (
89 $this->loadBalancerFactory->getLocalDomainID() === $wikiId ||
90 WikiMap::getWikiIdFromDbDomain( $this->loadBalancerFactory->getLocalDomainID() ) === $wikiId
91 )
92 ) {
93 $wikiId = DatabaseBlock::LOCAL;
94 }
95
96 $storeCacheKey = $wikiId === DatabaseBlock::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
97 if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
98 $this->storeCache[$storeCacheKey] = new DatabaseBlockStore(
99 $this->options,
100 $this->logger,
101 $this->actorStoreFactory,
102 $this->blockRestrictionStoreFactory->getBlockRestrictionStore( $wikiId ),
103 $this->commentStore,
104 $this->hookContainer,
105 $this->loadBalancerFactory,
106 $this->readOnlyMode,
107 $this->userFactory,
108 $this->tempUserConfig,
109 $this->crossWikiBlockTargetFactory->getFactory( $wikiId ),
110 $this->autoblockExemptionList,
111 $this->sessionManager,
112 $this->lockManager,
113 $wikiId
114 );
115 }
116 return $this->storeCache[$storeCacheKey];
117 }
118}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:72
Provides access to the wiki's autoblock exemption list.
__construct(ServiceOptions $options, LoggerInterface $logger, ActorStoreFactory $actorStoreFactory, BlockRestrictionStoreFactory $blockRestrictionStoreFactory, CommentStore $commentStore, HookContainer $hookContainer, LBFactory $loadBalancerFactory, ReadOnlyMode $readOnlyMode, UserFactory $userFactory, TempUserConfig $tempUserConfig, CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory, AutoblockExemptionList $autoblockExemptionList, SessionManagerInterface $sessionManager, ILockManager $lockManager)
getDatabaseBlockStore(string|false $wikiId=DatabaseBlock::LOCAL)
Handle database storage of comments such as edit summaries and log reasons.
A class for passing options to services.
ActorStore factory for any wiki domain.
Create User objects.
Tools for dealing with other locally-hosted wikis.
Definition WikiMap.php:19
Determine whether a site is currently in read-only mode.
const LOCAL
Wiki ID value to use with instances that are defined relative to the local wiki.
MediaWiki\Session entry point interface.
Interface for temporary user creation config and name matching.
Interface representing MediaWiki's LockManager.