MediaWiki 1.40.4
DatabaseBlockStoreFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Block;
22
29use Psr\Log\LoggerInterface;
30use ReadOnlyMode;
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 $configuredReadOnlyMode;
67
69 private $userFactory;
70
72 private $storeCache = [];
73
85 public function __construct(
86 ServiceOptions $options,
87 LoggerInterface $logger,
88 ActorStoreFactory $actorStoreFactory,
89 BlockRestrictionStoreFactory $blockRestrictionStoreFactory,
90 CommentStore $commentStore,
91 HookContainer $hookContainer,
92 LBFactory $loadBalancerFactory,
93 ConfiguredReadOnlyMode $configuredReadOnlyMode,
94 UserFactory $userFactory
95 ) {
96 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
97
98 $this->options = $options;
99 $this->logger = $logger;
100 $this->actorStoreFactory = $actorStoreFactory;
101 $this->blockRestrictionStoreFactory = $blockRestrictionStoreFactory;
102 $this->commentStore = $commentStore;
103 $this->hookContainer = $hookContainer;
104 $this->loadBalancerFactory = $loadBalancerFactory;
105 $this->configuredReadOnlyMode = $configuredReadOnlyMode;
106 $this->userFactory = $userFactory;
107 }
108
113 public function getDatabaseBlockStore( $wikiId = DatabaseBlock::LOCAL ): DatabaseBlockStore {
114 if ( is_string( $wikiId ) && $this->loadBalancerFactory->getLocalDomainID() === $wikiId ) {
115 $wikiId = DatabaseBlock::LOCAL;
116 }
117
118 $storeCacheKey = $wikiId === DatabaseBlock::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
119 if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
120 $loadBalancer = $this->loadBalancerFactory->getMainLB( $wikiId );
121 $this->storeCache[$storeCacheKey] = new DatabaseBlockStore(
122 $this->options,
123 $this->logger,
124 $this->actorStoreFactory,
125 $this->blockRestrictionStoreFactory->getBlockRestrictionStore( $wikiId ),
126 $this->commentStore,
127 $this->hookContainer,
128 $loadBalancer,
129 new ReadOnlyMode( $this->configuredReadOnlyMode, $loadBalancer ),
130 $this->userFactory,
131 $wikiId
132 );
133 }
134 return $this->storeCache[$storeCacheKey];
135 }
136}
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:88
A read-only mode service which does not depend on LoadBalancer.
__construct(ServiceOptions $options, LoggerInterface $logger, ActorStoreFactory $actorStoreFactory, BlockRestrictionStoreFactory $blockRestrictionStoreFactory, CommentStore $commentStore, HookContainer $hookContainer, LBFactory $loadBalancerFactory, ConfiguredReadOnlyMode $configuredReadOnlyMode, UserFactory $userFactory)
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.
A service class for fetching the wiki's current read-only mode.