MediaWiki master
DatabaseBlockStoreFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Block;
22
29use Psr\Log\LoggerInterface;
32
43
45 private $options;
46
48 private $logger;
49
51 private $actorStoreFactory;
52
54 private $blockRestrictionStoreFactory;
55
57 private $commentStore;
58
60 private $hookContainer;
61
63 private $loadBalancerFactory;
64
66 private $readOnlyMode;
67
69 private $userFactory;
70
72 private $tempUserConfig;
73
75 private $blockUtilsFactory;
76
78 private $autoblockExemptionList;
79
81 private $storeCache = [];
82
97 public function __construct(
98 ServiceOptions $options,
99 LoggerInterface $logger,
100 ActorStoreFactory $actorStoreFactory,
101 BlockRestrictionStoreFactory $blockRestrictionStoreFactory,
102 CommentStore $commentStore,
103 HookContainer $hookContainer,
104 LBFactory $loadBalancerFactory,
105 ReadOnlyMode $readOnlyMode,
106 UserFactory $userFactory,
107 TempUserConfig $tempUserConfig,
108 BlockUtilsFactory $blockUtilsFactory,
109 AutoblockExemptionList $autoblockExemptionList
110 ) {
111 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
112
113 $this->options = $options;
114 $this->logger = $logger;
115 $this->actorStoreFactory = $actorStoreFactory;
116 $this->blockRestrictionStoreFactory = $blockRestrictionStoreFactory;
117 $this->commentStore = $commentStore;
118 $this->hookContainer = $hookContainer;
119 $this->loadBalancerFactory = $loadBalancerFactory;
120 $this->readOnlyMode = $readOnlyMode;
121 $this->userFactory = $userFactory;
122 $this->tempUserConfig = $tempUserConfig;
123 $this->blockUtilsFactory = $blockUtilsFactory;
124 $this->autoblockExemptionList = $autoblockExemptionList;
125 }
126
131 public function getDatabaseBlockStore( $wikiId = DatabaseBlock::LOCAL ): DatabaseBlockStore {
132 if ( is_string( $wikiId ) && $this->loadBalancerFactory->getLocalDomainID() === $wikiId ) {
133 $wikiId = DatabaseBlock::LOCAL;
134 }
135
136 $storeCacheKey = $wikiId === DatabaseBlock::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
137 if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
138 $this->storeCache[$storeCacheKey] = new DatabaseBlockStore(
139 $this->options,
140 $this->logger,
141 $this->actorStoreFactory,
142 $this->blockRestrictionStoreFactory->getBlockRestrictionStore( $wikiId ),
143 $this->commentStore,
144 $this->hookContainer,
145 $this->loadBalancerFactory,
146 $this->readOnlyMode,
147 $this->userFactory,
148 $this->tempUserConfig,
149 $this->blockUtilsFactory->getBlockUtils( $wikiId ),
150 $this->autoblockExemptionList,
151 $wikiId
152 );
153 }
154 return $this->storeCache[$storeCacheKey];
155 }
156}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
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, BlockUtilsFactory $blockUtilsFactory, AutoblockExemptionList $autoblockExemptionList)
Handle database storage of comments such as edit summaries and log reasons.
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Creates User objects.
Determine whether a site is currently in read-only mode.
Interface for temporary user creation config and name matching.