MediaWiki  master
PageUpdaterFactory.php
Go to the documentation of this file.
1 <?php
23 namespace MediaWiki\Storage;
24 
25 use JobQueueGroup;
26 use Language;
43 use MessageCache;
44 use ParserCache;
45 use Psr\Log\LoggerInterface;
46 use TitleFormatter;
47 use WANObjectCache;
49 use WikiPage;
50 
58 
64  public const CONSTRUCTOR_OPTIONS = [
71  ];
72 
74  private $revisionStore;
75 
78 
81 
83  private $parserCache;
84 
86  private $jobQueueGroup;
87 
89  private $messageCache;
90 
92  private $contLang;
93 
96 
99 
101  private $hookContainer;
102 
105 
107  private $userNameUtils;
108 
110  private $logger;
111 
113  private $options;
114 
117 
120 
123 
126 
128  private $pageEditStash;
129 
132 
135 
138 
141 
143  private $softwareTags;
144 
171  public function __construct(
184  LoggerInterface $logger,
195  array $softwareTags
196  ) {
197  $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
198 
199  $this->revisionStore = $revisionStore;
200  $this->revisionRenderer = $revisionRenderer;
201  $this->slotRoleRegistry = $slotRoleRegistry;
202  $this->parserCache = $parserCache;
203  $this->jobQueueGroup = $jobQueueGroup;
204  $this->messageCache = $messageCache;
205  $this->contLang = $contLang;
206  $this->loadbalancerFactory = $loadbalancerFactory;
207  $this->contentHandlerFactory = $contentHandlerFactory;
208  $this->hookContainer = $hookContainer;
209  $this->editResultCache = $editResultCache;
210  $this->userNameUtils = $userNameUtils;
211  $this->logger = $logger;
212  $this->options = $options;
213  $this->userEditTracker = $userEditTracker;
214  $this->userGroupManager = $userGroupManager;
215  $this->titleFormatter = $titleFormatter;
216  $this->contentTransformer = $contentTransformer;
217  $this->pageEditStash = $pageEditStash;
218  $this->talkPageNotificationManager = $talkPageNotificationManager;
219  $this->mainWANObjectCache = $mainWANObjectCache;
220  $this->permissionManager = $permissionManager;
221  $this->softwareTags = $softwareTags;
222  $this->wikiPageFactory = $wikiPageFactory;
223  }
224 
239  public function newPageUpdater(
240  PageIdentity $page,
241  UserIdentity $user
242  ): PageUpdater {
243  $page = $this->wikiPageFactory->newFromTitle( $page );
244 
246  $page,
247  $user,
248  $this->newDerivedPageDataUpdater( $page )
249  );
250  }
251 
266  WikiPage $page,
267  UserIdentity $user,
268  DerivedPageDataUpdater $derivedPageDataUpdater
269  ): PageUpdater {
270  $pageUpdater = new PageUpdater(
271  $user,
272  $page, // NOTE: eventually, PageUpdater should not know about WikiPage
273  $derivedPageDataUpdater,
274  $this->loadbalancerFactory->getMainLB(),
275  $this->revisionStore,
276  $this->slotRoleRegistry,
277  $this->contentHandlerFactory,
278  $this->hookContainer,
279  $this->userEditTracker,
280  $this->userGroupManager,
281  $this->titleFormatter,
282  new ServiceOptions(
283  PageUpdater::CONSTRUCTOR_OPTIONS,
284  $this->options
285  ),
286  $this->softwareTags,
287  $this->logger
288  );
289 
290  $pageUpdater->setUsePageCreationLog(
291  $this->options->get( MainConfigNames::PageCreationLog ) );
292  $pageUpdater->setUseAutomaticEditSummaries(
293  $this->options->get( MainConfigNames::UseAutomaticEditSummaries )
294  );
295 
296  return $pageUpdater;
297  }
298 
308  $derivedDataUpdater = new DerivedPageDataUpdater(
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 }
Class to handle enqueueing of background jobs.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:45
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 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 instances.
IContentHandlerFactory $contentHandlerFactory
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.
TalkPageNotificationManager $talkPageNotificationManager
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.
Definition: PageUpdater.php:83
setUsePageCreationLog( $use)
Whether to create a log entry for new page creations.
Track info about user edit counts and timings.
UserNameUtils service.
Cache of messages that are defined by MediaWiki namespace pages or by hooks.
Cache for ParserOutput objects corresponding to the latest page revisions.
Definition: ParserCache.php:63
Multi-datacenter aware caching interface.
Base representation for an editable wiki page.
Definition: WikiPage.php:62
Interface for objects (potentially) representing an editable wiki page.
Interface for objects representing user identity.
A title formatter service for MediaWiki.
An interface for generating database load balancers.
Definition: ILBFactory.php:34