MediaWiki  master
PageUpdaterFactory.php
Go to the documentation of this file.
1 <?php
23 namespace MediaWiki\Storage;
24 
25 use JobQueueGroup;
26 use Language;
40 use MessageCache;
41 use ParserCache;
42 use Psr\Log\LoggerInterface;
43 use TitleFormatter;
44 use WANObjectCache;
46 use WikiPage;
47 
55 
61  public const CONSTRUCTOR_OPTIONS = [
62  'ArticleCountMethod',
63  'RCWatchCategoryMembership',
64  'PageCreationLog',
65  'UseAutomaticEditSummaries',
66  'ManualRevertSearchRadius',
67  'UseRCPatrol',
68  ];
69 
71  private $revisionStore;
72 
75 
78 
80  private $parserCache;
81 
83  private $jobQueueGroup;
84 
86  private $messageCache;
87 
89  private $contLang;
90 
93 
96 
98  private $hookContainer;
99 
102 
104  private $userNameUtils;
105 
107  private $logger;
108 
110  private $options;
111 
114 
117 
120 
123 
125  private $pageEditStash;
126 
129 
132 
135 
137  private $softwareTags;
138 
164  public function __construct(
177  LoggerInterface $logger,
187  array $softwareTags
188  ) {
189  $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
190 
191  $this->revisionStore = $revisionStore;
192  $this->revisionRenderer = $revisionRenderer;
193  $this->slotRoleRegistry = $slotRoleRegistry;
194  $this->parserCache = $parserCache;
195  $this->jobQueueGroup = $jobQueueGroup;
196  $this->messageCache = $messageCache;
197  $this->contLang = $contLang;
198  $this->loadbalancerFactory = $loadbalancerFactory;
199  $this->contentHandlerFactory = $contentHandlerFactory;
200  $this->hookContainer = $hookContainer;
201  $this->editResultCache = $editResultCache;
202  $this->userNameUtils = $userNameUtils;
203  $this->logger = $logger;
204  $this->options = $options;
205  $this->userEditTracker = $userEditTracker;
206  $this->userGroupManager = $userGroupManager;
207  $this->titleFormatter = $titleFormatter;
208  $this->contentTransformer = $contentTransformer;
209  $this->pageEditStash = $pageEditStash;
210  $this->talkPageNotificationManager = $talkPageNotificationManager;
211  $this->mainWANObjectCache = $mainWANObjectCache;
212  $this->permissionManager = $permissionManager;
213  $this->softwareTags = $softwareTags;
214  }
215 
230  public function newPageUpdater(
231  WikiPage $page,
232  UserIdentity $user
233  ): PageUpdater {
235  $page,
236  $user,
237  $this->newDerivedPageDataUpdater( $page )
238  );
239  }
240 
255  WikiPage $page,
256  UserIdentity $user,
257  DerivedPageDataUpdater $derivedPageDataUpdater
258  ): PageUpdater {
259  $pageUpdater = new PageUpdater(
260  $user,
261  $page, // NOTE: eventually, PageUpdater should not know about WikiPage
262  $derivedPageDataUpdater,
263  $this->loadbalancerFactory->getMainLB(),
264  $this->revisionStore,
265  $this->slotRoleRegistry,
266  $this->contentHandlerFactory,
267  $this->hookContainer,
268  $this->userEditTracker,
269  $this->userGroupManager,
270  $this->titleFormatter,
271  new ServiceOptions(
273  $this->options
274  ),
275  $this->softwareTags
276  );
277 
278  $pageUpdater->setUsePageCreationLog( $this->options->get( 'PageCreationLog' ) );
279  $pageUpdater->setUseAutomaticEditSummaries(
280  $this->options->get( 'UseAutomaticEditSummaries' )
281  );
282 
283  return $pageUpdater;
284  }
285 
295  $derivedDataUpdater = new DerivedPageDataUpdater(
296  $page, // NOTE: eventually, PageUpdater should not know about WikiPage
297  $this->revisionStore,
298  $this->revisionRenderer,
299  $this->slotRoleRegistry,
300  $this->parserCache,
301  $this->jobQueueGroup,
302  $this->messageCache,
303  $this->contLang,
304  $this->loadbalancerFactory,
305  $this->contentHandlerFactory,
306  $this->hookContainer,
307  $this->editResultCache,
308  $this->userNameUtils,
309  $this->contentTransformer,
310  $this->pageEditStash,
311  $this->talkPageNotificationManager,
312  $this->mainWANObjectCache,
313  $this->permissionManager
314  );
315 
316  $derivedDataUpdater->setLogger( $this->logger );
317  $derivedDataUpdater->setArticleCountMethod( $this->options->get( 'ArticleCountMethod' ) );
318  $derivedDataUpdater->setRcWatchCategoryMembership(
319  $this->options->get( 'RCWatchCategoryMembership' )
320  );
321 
322  return $derivedDataUpdater;
323  }
324 
325 }
MediaWiki\Storage\PageUpdaterFactory\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Options that have to be present in the ServiceOptions object passed to the constructor.
Definition: PageUpdaterFactory.php:61
MediaWiki\Storage\PageUpdaterFactory\$contentTransformer
ContentTransformer $contentTransformer
Definition: PageUpdaterFactory.php:122
MediaWiki\Storage\PageUpdaterFactory\$userNameUtils
UserNameUtils $userNameUtils
Definition: PageUpdaterFactory.php:104
MediaWiki\Storage\PageUpdaterFactory\newDerivedPageDataUpdater
newDerivedPageDataUpdater(WikiPage $page)
Definition: PageUpdaterFactory.php:294
MediaWiki\Storage\PageUpdaterFactory\$options
ServiceOptions $options
Definition: PageUpdaterFactory.php:110
MediaWiki\Storage\PageUpdater\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Options that have to be present in the ServiceOptions object passed to the constructor.
Definition: PageUpdater.php:86
MediaWiki\Storage\PageUpdaterFactory\$contLang
Language $contLang
Definition: PageUpdaterFactory.php:89
MediaWiki\Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:88
MediaWiki\Storage\PageUpdaterFactory\$parserCache
ParserCache $parserCache
Definition: PageUpdaterFactory.php:80
MediaWiki\Storage\PageUpdaterFactory\$jobQueueGroup
JobQueueGroup $jobQueueGroup
Definition: PageUpdaterFactory.php:83
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:60
MediaWiki\Storage\PageUpdaterFactory\__construct
__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, array $softwareTags)
Definition: PageUpdaterFactory.php:164
MediaWiki\Storage\PageUpdaterFactory\$logger
LoggerInterface $logger
Definition: PageUpdaterFactory.php:107
MediaWiki\Storage\PageUpdaterFactory\$mainWANObjectCache
WANObjectCache $mainWANObjectCache
Definition: PageUpdaterFactory.php:131
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
MediaWiki\Storage\PageUpdaterFactory\$revisionStore
RevisionStore $revisionStore
Definition: PageUpdaterFactory.php:71
MediaWiki\User\TalkPageNotificationManager
Manages user talk page notifications.
Definition: TalkPageNotificationManager.php:35
MediaWiki\User\UserGroupManager
Managers user groups.
Definition: UserGroupManager.php:52
MediaWiki\Storage\PageUpdaterFactory\$editResultCache
EditResultCache $editResultCache
Definition: PageUpdaterFactory.php:101
MediaWiki\Storage\PageUpdaterFactory\$revisionRenderer
RevisionRenderer $revisionRenderer
Definition: PageUpdaterFactory.php:74
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:27
MediaWiki\Storage\PageEditStash
Class for managing stashed edits used by the page updater classes.
Definition: PageEditStash.php:48
MediaWiki\Storage\PageUpdaterFactory\$userEditTracker
UserEditTracker $userEditTracker
Definition: PageUpdaterFactory.php:113
MediaWiki\Content\Transform\ContentTransformer
A service to transform content.
Definition: ContentTransformer.php:15
MediaWiki\Storage\PageUpdaterFactory\$softwareTags
string[] $softwareTags
Definition: PageUpdaterFactory.php:137
MediaWiki\Storage\PageUpdaterFactory\$hookContainer
HookContainer $hookContainer
Definition: PageUpdaterFactory.php:98
MediaWiki\Revision\RevisionRenderer
The RevisionRenderer service provides access to rendered output for revisions.
Definition: RevisionRenderer.php:45
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:53
MediaWiki\Content\IContentHandlerFactory
Definition: IContentHandlerFactory.php:10
MediaWiki\Storage\EditResultCache
Class allowing easy storage and retrieval of EditResults associated with revisions.
Definition: EditResultCache.php:42
MediaWiki\Storage\PageUpdater
Controller-like object for creating and updating pages by creating new revisions.
Definition: PageUpdater.php:79
MediaWiki\Storage\PageUpdaterFactory\$messageCache
MessageCache $messageCache
Definition: PageUpdaterFactory.php:86
WANObjectCache
Multi-datacenter aware caching interface.
Definition: WANObjectCache.php:128
MediaWiki\Storage\PageUpdaterFactory\$titleFormatter
TitleFormatter $titleFormatter
Definition: PageUpdaterFactory.php:119
MediaWiki\Storage\PageUpdaterFactory\newPageUpdaterForDerivedPageDataUpdater
newPageUpdaterForDerivedPageDataUpdater(WikiPage $page, UserIdentity $user, DerivedPageDataUpdater $derivedPageDataUpdater)
Return a PageUpdater for building an update to a page, reusing the state of an existing DerivedPageDa...
Definition: PageUpdaterFactory.php:254
MediaWiki\Storage\PageUpdaterFactory\newPageUpdater
newPageUpdater(WikiPage $page, UserIdentity $user)
Return a PageUpdater for building an update to a page.
Definition: PageUpdaterFactory.php:230
MediaWiki\Storage\PageUpdaterFactory\$pageEditStash
PageEditStash $pageEditStash
Definition: PageUpdaterFactory.php:125
MediaWiki\Storage
Definition: BlobAccessException.php:23
MediaWiki\User\UserEditTracker
Track info about user edit counts and timings.
Definition: UserEditTracker.php:21
MediaWiki\Storage\PageUpdaterFactory\$loadbalancerFactory
ILBFactory $loadbalancerFactory
Definition: PageUpdaterFactory.php:92
MediaWiki\User\UserNameUtils
UserNameUtils service.
Definition: UserNameUtils.php:42
TitleFormatter
A title formatter service for MediaWiki.
Definition: TitleFormatter.php:35
MediaWiki\Storage\PageUpdaterFactory\$talkPageNotificationManager
TalkPageNotificationManager $talkPageNotificationManager
Definition: PageUpdaterFactory.php:128
MediaWiki\Storage\PageUpdaterFactory\$contentHandlerFactory
IContentHandlerFactory $contentHandlerFactory
Definition: PageUpdaterFactory.php:95
MediaWiki\Storage\PageUpdaterFactory\$slotRoleRegistry
SlotRoleRegistry $slotRoleRegistry
Definition: PageUpdaterFactory.php:77
ParserCache
Cache for ParserOutput objects corresponding to the latest page revisions.
Definition: ParserCache.php:63
MediaWiki\Storage\PageUpdaterFactory
A factory for PageUpdater instances.
Definition: PageUpdaterFactory.php:54
MediaWiki\Storage\PageUpdaterFactory\$userGroupManager
UserGroupManager $userGroupManager
Definition: PageUpdaterFactory.php:116
MediaWiki\Revision\SlotRoleRegistry
A registry service for SlotRoleHandlers, used to define which slot roles are available on which page.
Definition: SlotRoleRegistry.php:48
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:45
MediaWiki\Storage\DerivedPageDataUpdater
A handle for managing updates for derived page data on edit, import, purge, etc.
Definition: DerivedPageDataUpdater.php:105
MessageCache
Cache of messages that are defined by MediaWiki namespace pages or by hooks.
Definition: MessageCache.php:52
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:42
MediaWiki\Config\ServiceOptions\assertRequiredOptions
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Definition: ServiceOptions.php:71
Wikimedia\Rdbms\ILBFactory
An interface for generating database load balancers.
Definition: ILBFactory.php:33
JobQueueGroup
Class to handle enqueueing of background jobs.
Definition: JobQueueGroup.php:32
MediaWiki\Storage\PageUpdaterFactory\$permissionManager
PermissionManager $permissionManager
Definition: PageUpdaterFactory.php:134