MediaWiki master
DatabaseBlockStoreFactory.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Block;
8
16use Psr\Log\LoggerInterface;
19
30
31 private ServiceOptions $options;
32 private LoggerInterface $logger;
33 private ActorStoreFactory $actorStoreFactory;
34 private BlockRestrictionStoreFactory $blockRestrictionStoreFactory;
35 private CommentStore $commentStore;
36 private HookContainer $hookContainer;
37 private LBFactory $loadBalancerFactory;
38 private ReadOnlyMode $readOnlyMode;
39 private UserFactory $userFactory;
40 private TempUserConfig $tempUserConfig;
41 private CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory;
42 private AutoblockExemptionList $autoblockExemptionList;
43 private SessionManagerInterface $sessionManager;
44
46 private array $storeCache = [];
47
48 public function __construct(
49 ServiceOptions $options,
50 LoggerInterface $logger,
51 ActorStoreFactory $actorStoreFactory,
52 BlockRestrictionStoreFactory $blockRestrictionStoreFactory,
53 CommentStore $commentStore,
54 HookContainer $hookContainer,
55 LBFactory $loadBalancerFactory,
56 ReadOnlyMode $readOnlyMode,
57 UserFactory $userFactory,
58 TempUserConfig $tempUserConfig,
59 CrossWikiBlockTargetFactory $crossWikiBlockTargetFactory,
60 AutoblockExemptionList $autoblockExemptionList,
61 SessionManagerInterface $sessionManager
62 ) {
63 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
64
65 $this->options = $options;
66 $this->logger = $logger;
67 $this->actorStoreFactory = $actorStoreFactory;
68 $this->blockRestrictionStoreFactory = $blockRestrictionStoreFactory;
69 $this->commentStore = $commentStore;
70 $this->hookContainer = $hookContainer;
71 $this->loadBalancerFactory = $loadBalancerFactory;
72 $this->readOnlyMode = $readOnlyMode;
73 $this->userFactory = $userFactory;
74 $this->tempUserConfig = $tempUserConfig;
75 $this->crossWikiBlockTargetFactory = $crossWikiBlockTargetFactory;
76 $this->autoblockExemptionList = $autoblockExemptionList;
77 $this->sessionManager = $sessionManager;
78 }
79
80 public function getDatabaseBlockStore( string|false $wikiId = DatabaseBlock::LOCAL ): DatabaseBlockStore {
81 if ( is_string( $wikiId ) && $this->loadBalancerFactory->getLocalDomainID() === $wikiId ) {
82 $wikiId = DatabaseBlock::LOCAL;
83 }
84
85 $storeCacheKey = $wikiId === DatabaseBlock::LOCAL ? 'LOCAL' : 'crosswikistore-' . $wikiId;
86 if ( !isset( $this->storeCache[$storeCacheKey] ) ) {
87 $this->storeCache[$storeCacheKey] = new DatabaseBlockStore(
88 $this->options,
89 $this->logger,
90 $this->actorStoreFactory,
91 $this->blockRestrictionStoreFactory->getBlockRestrictionStore( $wikiId ),
92 $this->commentStore,
93 $this->hookContainer,
94 $this->loadBalancerFactory,
95 $this->readOnlyMode,
96 $this->userFactory,
97 $this->tempUserConfig,
98 $this->crossWikiBlockTargetFactory->getFactory( $wikiId ),
99 $this->autoblockExemptionList,
100 $this->sessionManager,
101 $wikiId
102 );
103 }
104 return $this->storeCache[$storeCacheKey];
105 }
106}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
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)
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.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
ActorStore factory for any wiki domain.
Create User objects.
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.