MediaWiki master
PageUpdaterFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Storage;
22
24use Language;
42use MessageCache;
43use ParserCache;
44use Psr\Log\LoggerInterface;
47use WikiPage;
48
56
62 public const CONSTRUCTOR_OPTIONS = [
70 ];
71
73 private $revisionStore;
74
76 private $revisionRenderer;
77
79 private $slotRoleRegistry;
80
82 private $parserCache;
83
85 private $jobQueueGroup;
86
88 private $messageCache;
89
91 private $contLang;
92
94 private $loadbalancerFactory;
95
97 private $contentHandlerFactory;
98
100 private $hookContainer;
101
103 private $editResultCache;
104
106 private $userNameUtils;
107
109 private $logger;
110
112 private $options;
113
115 private $userEditTracker;
116
118 private $userGroupManager;
119
121 private $titleFormatter;
122
124 private $contentTransformer;
125
127 private $pageEditStash;
128
130 private $talkPageNotificationManager;
131
133 private $mainWANObjectCache;
134
136 private $permissionManager;
137
139 private $wikiPageFactory;
140
142 private $softwareTags;
143
170 public function __construct(
171 RevisionStore $revisionStore,
172 RevisionRenderer $revisionRenderer,
173 SlotRoleRegistry $slotRoleRegistry,
174 ParserCache $parserCache,
175 JobQueueGroup $jobQueueGroup,
176 MessageCache $messageCache,
177 Language $contLang,
178 ILBFactory $loadbalancerFactory,
179 IContentHandlerFactory $contentHandlerFactory,
180 HookContainer $hookContainer,
181 EditResultCache $editResultCache,
182 UserNameUtils $userNameUtils,
183 LoggerInterface $logger,
184 ServiceOptions $options,
185 UserEditTracker $userEditTracker,
186 UserGroupManager $userGroupManager,
187 TitleFormatter $titleFormatter,
188 ContentTransformer $contentTransformer,
189 PageEditStash $pageEditStash,
190 TalkPageNotificationManager $talkPageNotificationManager,
191 WANObjectCache $mainWANObjectCache,
192 PermissionManager $permissionManager,
193 WikiPageFactory $wikiPageFactory,
194 array $softwareTags
195 ) {
196 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
197
198 $this->revisionStore = $revisionStore;
199 $this->revisionRenderer = $revisionRenderer;
200 $this->slotRoleRegistry = $slotRoleRegistry;
201 $this->parserCache = $parserCache;
202 $this->jobQueueGroup = $jobQueueGroup;
203 $this->messageCache = $messageCache;
204 $this->contLang = $contLang;
205 $this->loadbalancerFactory = $loadbalancerFactory;
206 $this->contentHandlerFactory = $contentHandlerFactory;
207 $this->hookContainer = $hookContainer;
208 $this->editResultCache = $editResultCache;
209 $this->userNameUtils = $userNameUtils;
210 $this->logger = $logger;
211 $this->options = $options;
212 $this->userEditTracker = $userEditTracker;
213 $this->userGroupManager = $userGroupManager;
214 $this->titleFormatter = $titleFormatter;
215 $this->contentTransformer = $contentTransformer;
216 $this->pageEditStash = $pageEditStash;
217 $this->talkPageNotificationManager = $talkPageNotificationManager;
218 $this->mainWANObjectCache = $mainWANObjectCache;
219 $this->permissionManager = $permissionManager;
220 $this->softwareTags = $softwareTags;
221 $this->wikiPageFactory = $wikiPageFactory;
222 }
223
238 public function newPageUpdater(
239 PageIdentity $page,
240 UserIdentity $user
241 ): PageUpdater {
242 $page = $this->wikiPageFactory->newFromTitle( $page );
243
245 $page,
246 $user,
247 $this->newDerivedPageDataUpdater( $page )
248 );
249 }
250
265 WikiPage $page,
266 UserIdentity $user,
267 DerivedPageDataUpdater $derivedPageDataUpdater
268 ): PageUpdater {
269 $pageUpdater = new PageUpdater(
270 $user,
271 $page, // NOTE: eventually, PageUpdater should not know about WikiPage
272 $derivedPageDataUpdater,
273 $this->loadbalancerFactory,
274 $this->revisionStore,
275 $this->slotRoleRegistry,
276 $this->contentHandlerFactory,
277 $this->hookContainer,
278 $this->userEditTracker,
279 $this->userGroupManager,
280 $this->titleFormatter,
281 new ServiceOptions(
282 PageUpdater::CONSTRUCTOR_OPTIONS,
283 $this->options
284 ),
285 $this->softwareTags,
286 $this->logger
287 );
288
289 $pageUpdater->setUsePageCreationLog(
290 $this->options->get( MainConfigNames::PageCreationLog ) );
291 $pageUpdater->setUseAutomaticEditSummaries(
292 $this->options->get( MainConfigNames::UseAutomaticEditSummaries )
293 );
294
295 return $pageUpdater;
296 }
297
307 $derivedDataUpdater = new DerivedPageDataUpdater(
308 $this->options,
309 $page, // NOTE: eventually, PageUpdater should not know about WikiPage
310 $this->revisionStore,
311 $this->revisionRenderer,
312 $this->slotRoleRegistry,
313 $this->parserCache,
314 $this->jobQueueGroup,
315 $this->messageCache,
316 $this->contLang,
317 $this->loadbalancerFactory,
318 $this->contentHandlerFactory,
319 $this->hookContainer,
320 $this->editResultCache,
321 $this->userNameUtils,
322 $this->contentTransformer,
323 $this->pageEditStash,
324 $this->talkPageNotificationManager,
325 $this->mainWANObjectCache,
326 $this->permissionManager
327 );
328
329 $derivedDataUpdater->setLogger( $this->logger );
330 $derivedDataUpdater->setArticleCountMethod(
331 $this->options->get( MainConfigNames::ArticleCountMethod ) );
332 $derivedDataUpdater->setRcWatchCategoryMembership(
333 $this->options->get( MainConfigNames::RCWatchCategoryMembership )
334 );
335
336 return $derivedDataUpdater;
337 }
338
339}
Handle enqueueing of background jobs.
Base class for language-specific code.
Definition Language.php:65
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
A class containing constants representing the names of configuration variables.
const UseRCPatrol
Name constant for the UseRCPatrol setting, for use with Config::get()
const ArticleCountMethod
Name constant for the ArticleCountMethod setting, for use with Config::get()
const ManualRevertSearchRadius
Name constant for the ManualRevertSearchRadius setting, for use with Config::get()
const PageCreationLog
Name constant for the PageCreationLog setting, for use with Config::get()
const RCWatchCategoryMembership
Name constant for the RCWatchCategoryMembership setting, for use with Config::get()
const ParsoidCacheConfig
Name constant for the ParsoidCacheConfig setting, for use with Config::get()
const UseAutomaticEditSummaries
Name constant for the UseAutomaticEditSummaries setting, for use with Config::get()
Service for creating WikiPage objects.
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
The RevisionRenderer service provides access to rendered output for revisions.
Service for looking up page revisions.
A registry service for SlotRoleHandlers, used to define which slot roles are available on which page.
A handle for managing updates for derived page data on edit, import, purge, etc.
Class allowing easy storage and retrieval of EditResults associated with revisions.
Manage the pre-emptive page parsing for edits to wiki pages.
A factory for PageUpdater and DerivedPageDataUpdater instances.
newPageUpdaterForDerivedPageDataUpdater(WikiPage $page, UserIdentity $user, DerivedPageDataUpdater $derivedPageDataUpdater)
Return a PageUpdater for building an update to a page, reusing the state of an existing DerivedPageDa...
newPageUpdater(PageIdentity $page, UserIdentity $user)
Return a PageUpdater for building an update to a page.
const CONSTRUCTOR_OPTIONS
Options that have to be present in the ServiceOptions object passed to the constructor.
__construct(RevisionStore $revisionStore, RevisionRenderer $revisionRenderer, SlotRoleRegistry $slotRoleRegistry, ParserCache $parserCache, JobQueueGroup $jobQueueGroup, MessageCache $messageCache, Language $contLang, ILBFactory $loadbalancerFactory, IContentHandlerFactory $contentHandlerFactory, HookContainer $hookContainer, EditResultCache $editResultCache, UserNameUtils $userNameUtils, LoggerInterface $logger, ServiceOptions $options, UserEditTracker $userEditTracker, UserGroupManager $userGroupManager, TitleFormatter $titleFormatter, ContentTransformer $contentTransformer, PageEditStash $pageEditStash, TalkPageNotificationManager $talkPageNotificationManager, WANObjectCache $mainWANObjectCache, PermissionManager $permissionManager, WikiPageFactory $wikiPageFactory, array $softwareTags)
Controller-like object for creating and updating pages by creating new revisions.
setUsePageCreationLog( $use)
Whether to create a log entry for new page creations.
Track info about user edit counts and timings.
UserNameUtils service.
Cache messages that are defined by MediaWiki-namespace pages or by hooks.
Cache for ParserOutput objects corresponding to the latest page revisions.
Multi-datacenter aware caching interface.
Base representation for an editable wiki page.
Definition WikiPage.php:79
Interface for objects (potentially) representing an editable wiki page.
A title formatter service for MediaWiki.
Interface for objects representing user identity.
Manager of ILoadBalancer objects and, indirectly, IDatabase connections.