MediaWiki master
DatabaseBlockStoreFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Block;
22
29use Psr\Log\LoggerInterface;
32
43
44 private ServiceOptions $options;
45 private LoggerInterface $logger;
46 private ActorStoreFactory $actorStoreFactory;
47 private BlockRestrictionStoreFactory $blockRestrictionStoreFactory;
48 private CommentStore $commentStore;
49 private HookContainer $hookContainer;
50 private LBFactory $loadBalancerFactory;
51 private ReadOnlyMode $readOnlyMode;
52 private UserFactory $userFactory;
53 private TempUserConfig $tempUserConfig;
54 private BlockUtilsFactory $blockUtilsFactory;
55 private AutoblockExemptionList $autoblockExemptionList;
56
58 private array $storeCache = [];
59
60 public function __construct(
61 ServiceOptions $options,
62 LoggerInterface $logger,
63 ActorStoreFactory $actorStoreFactory,
64 BlockRestrictionStoreFactory $blockRestrictionStoreFactory,
65 CommentStore $commentStore,
66 HookContainer $hookContainer,
67 LBFactory $loadBalancerFactory,
68 ReadOnlyMode $readOnlyMode,
69 UserFactory $userFactory,
70 TempUserConfig $tempUserConfig,
71 BlockUtilsFactory $blockUtilsFactory,
72 AutoblockExemptionList $autoblockExemptionList
73 ) {
74 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
75
76 $this->options = $options;
77 $this->logger = $logger;
78 $this->actorStoreFactory = $actorStoreFactory;
79 $this->blockRestrictionStoreFactory = $blockRestrictionStoreFactory;
80 $this->commentStore = $commentStore;
81 $this->hookContainer = $hookContainer;
82 $this->loadBalancerFactory = $loadBalancerFactory;
83 $this->readOnlyMode = $readOnlyMode;
84 $this->userFactory = $userFactory;
85 $this->tempUserConfig = $tempUserConfig;
86 $this->blockUtilsFactory = $blockUtilsFactory;
87 $this->autoblockExemptionList = $autoblockExemptionList;
88 }
89
94 public function getDatabaseBlockStore( $wikiId = DatabaseBlock::LOCAL ): DatabaseBlockStore {
95 if ( is_string( $wikiId ) && $this->loadBalancerFactory->getLocalDomainID() === $wikiId ) {
96 $wikiId = DatabaseBlock::LOCAL;
97 }
98
99 $storeCacheKey = $wikiId === DatabaseBlock::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
100 if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
101 $this->storeCache[$storeCacheKey] = new DatabaseBlockStore(
102 $this->options,
103 $this->logger,
104 $this->actorStoreFactory,
105 $this->blockRestrictionStoreFactory->getBlockRestrictionStore( $wikiId ),
106 $this->commentStore,
107 $this->hookContainer,
108 $this->loadBalancerFactory,
109 $this->readOnlyMode,
110 $this->userFactory,
111 $this->tempUserConfig,
112 $this->blockUtilsFactory->getBlockUtils( $wikiId ),
113 $this->autoblockExemptionList,
114 $wikiId
115 );
116 }
117 return $this->storeCache[$storeCacheKey];
118 }
119}
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.