Merge ".mailmap: Correct two contributor names"
[mediawiki.git] / includes / page / PageCommandFactory.php
bloba64b0b9444f298efc1005775f40b7f3c6c6cdacf
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @author DannyS712
22 namespace MediaWiki\Page;
24 use JobQueueGroup;
25 use LogFormatterFactory;
26 use MediaWiki\Cache\BacklinkCacheFactory;
27 use MediaWiki\Collation\CollationFactory;
28 use MediaWiki\CommentStore\CommentStore;
29 use MediaWiki\Config\Config;
30 use MediaWiki\Config\ServiceOptions;
31 use MediaWiki\Content\ContentModelChange;
32 use MediaWiki\Content\IContentHandlerFactory;
33 use MediaWiki\EditPage\SpamChecker;
34 use MediaWiki\HookContainer\HookContainer;
35 use MediaWiki\Linker\LinkTargetLookup;
36 use MediaWiki\Permissions\Authority;
37 use MediaWiki\Permissions\RestrictionStore;
38 use MediaWiki\Revision\ArchivedRevisionLookup;
39 use MediaWiki\Revision\RevisionStoreFactory;
40 use MediaWiki\Storage\PageUpdaterFactory;
41 use MediaWiki\Title\NamespaceInfo;
42 use MediaWiki\Title\Title;
43 use MediaWiki\Title\TitleFactory;
44 use MediaWiki\Title\TitleFormatter;
45 use MediaWiki\User\ActorMigration;
46 use MediaWiki\User\ActorNormalization;
47 use MediaWiki\User\UserEditTracker;
48 use MediaWiki\User\UserFactory;
49 use MediaWiki\User\UserIdentity;
50 use MediaWiki\Watchlist\WatchedItemStoreInterface;
51 use Psr\Log\LoggerInterface;
52 use RepoGroup;
53 use Wikimedia\Message\ITextFormatter;
54 use Wikimedia\ObjectCache\BagOStuff;
55 use Wikimedia\Rdbms\LBFactory;
56 use Wikimedia\Rdbms\ReadOnlyMode;
58 /**
59 * Implementation of various page action services.
61 * @internal
63 class PageCommandFactory implements
64 ContentModelChangeFactory,
65 DeletePageFactory,
66 MergeHistoryFactory,
67 MovePageFactory,
68 RollbackPageFactory,
69 UndeletePageFactory
72 private Config $config;
73 private LBFactory $lbFactory;
74 private NamespaceInfo $namespaceInfo;
75 private WatchedItemStoreInterface $watchedItemStore;
76 private RepoGroup $repoGroup;
77 private ReadOnlyMode $readOnlyMode;
78 private IContentHandlerFactory $contentHandlerFactory;
79 private RevisionStoreFactory $revisionStoreFactory;
80 private SpamChecker $spamChecker;
81 private TitleFormatter $titleFormatter;
82 private HookContainer $hookContainer;
83 private WikiPageFactory $wikiPageFactory;
84 private UserFactory $userFactory;
85 private ActorMigration $actorMigration;
86 private ActorNormalization $actorNormalization;
87 private TitleFactory $titleFactory;
88 private UserEditTracker $userEditTracker;
89 private CollationFactory $collationFactory;
90 private JobQueueGroup $jobQueueGroup;
91 private CommentStore $commentStore;
92 private BagOStuff $mainStash;
93 private string $localWikiID;
94 private string $webRequestID;
95 private BacklinkCacheFactory $backlinkCacheFactory;
96 private LoggerInterface $undeletePageLogger;
97 private PageUpdaterFactory $pageUpdaterFactory;
98 private ITextFormatter $contLangMsgTextFormatter;
99 private ArchivedRevisionLookup $archivedRevisionLookup;
100 private RestrictionStore $restrictionStore;
101 private LinkTargetLookup $linkTargetLookup;
102 private RedirectStore $redirectStore;
103 private LogFormatterFactory $logFormatterFactory;
105 public function __construct(
106 Config $config,
107 LBFactory $lbFactory,
108 NamespaceInfo $namespaceInfo,
109 WatchedItemStoreInterface $watchedItemStore,
110 RepoGroup $repoGroup,
111 ReadOnlyMode $readOnlyMode,
112 IContentHandlerFactory $contentHandlerFactory,
113 RevisionStoreFactory $revisionStoreFactory,
114 SpamChecker $spamChecker,
115 TitleFormatter $titleFormatter,
116 HookContainer $hookContainer,
117 WikiPageFactory $wikiPageFactory,
118 UserFactory $userFactory,
119 ActorMigration $actorMigration,
120 ActorNormalization $actorNormalization,
121 TitleFactory $titleFactory,
122 UserEditTracker $userEditTracker,
123 CollationFactory $collationFactory,
124 JobQueueGroup $jobQueueGroup,
125 CommentStore $commentStore,
126 BagOStuff $mainStash,
127 string $localWikiID,
128 string $webRequestID,
129 BacklinkCacheFactory $backlinkCacheFactory,
130 LoggerInterface $undeletePageLogger,
131 PageUpdaterFactory $pageUpdaterFactory,
132 ITextFormatter $contLangMsgTextFormatter,
133 ArchivedRevisionLookup $archivedRevisionLookup,
134 RestrictionStore $restrictionStore,
135 LinkTargetLookup $linkTargetLookup,
136 RedirectStore $redirectStore,
137 LogFormatterFactory $logFormatterFactory
139 $this->config = $config;
140 $this->lbFactory = $lbFactory;
141 $this->namespaceInfo = $namespaceInfo;
142 $this->watchedItemStore = $watchedItemStore;
143 $this->repoGroup = $repoGroup;
144 $this->readOnlyMode = $readOnlyMode;
145 $this->contentHandlerFactory = $contentHandlerFactory;
146 $this->revisionStoreFactory = $revisionStoreFactory;
147 $this->spamChecker = $spamChecker;
148 $this->titleFormatter = $titleFormatter;
149 $this->hookContainer = $hookContainer;
150 $this->wikiPageFactory = $wikiPageFactory;
151 $this->userFactory = $userFactory;
152 $this->actorMigration = $actorMigration;
153 $this->actorNormalization = $actorNormalization;
154 $this->titleFactory = $titleFactory;
155 $this->userEditTracker = $userEditTracker;
156 $this->collationFactory = $collationFactory;
157 $this->jobQueueGroup = $jobQueueGroup;
158 $this->commentStore = $commentStore;
159 $this->mainStash = $mainStash;
160 $this->localWikiID = $localWikiID;
161 $this->webRequestID = $webRequestID;
162 $this->backlinkCacheFactory = $backlinkCacheFactory;
163 $this->undeletePageLogger = $undeletePageLogger;
164 $this->pageUpdaterFactory = $pageUpdaterFactory;
165 $this->contLangMsgTextFormatter = $contLangMsgTextFormatter;
166 $this->archivedRevisionLookup = $archivedRevisionLookup;
167 $this->restrictionStore = $restrictionStore;
168 $this->linkTargetLookup = $linkTargetLookup;
169 $this->redirectStore = $redirectStore;
170 $this->logFormatterFactory = $logFormatterFactory;
174 * @param Authority $performer
175 * @param PageIdentity $page
176 * @param string $newContentModel
177 * @return ContentModelChange
179 public function newContentModelChange(
180 Authority $performer,
181 PageIdentity $page,
182 string $newContentModel
183 ): ContentModelChange {
184 return new ContentModelChange(
185 $this->contentHandlerFactory,
186 $this->hookContainer,
187 $this->revisionStoreFactory->getRevisionStore(),
188 $this->userFactory,
189 $this->wikiPageFactory,
190 $this->logFormatterFactory,
191 $performer,
192 $page,
193 $newContentModel
198 * @inheritDoc
200 public function newDeletePage( ProperPageIdentity $page, Authority $deleter ): DeletePage {
201 return new DeletePage(
202 $this->hookContainer,
203 $this->revisionStoreFactory->getRevisionStore(),
204 $this->lbFactory,
205 $this->jobQueueGroup,
206 $this->commentStore,
207 new ServiceOptions( DeletePage::CONSTRUCTOR_OPTIONS, $this->config ),
208 $this->mainStash,
209 $this->localWikiID,
210 $this->webRequestID,
211 $this->wikiPageFactory,
212 $this->userFactory,
213 $this->backlinkCacheFactory,
214 $this->namespaceInfo,
215 $this->contLangMsgTextFormatter,
216 $this->redirectStore,
217 $page,
218 $deleter
223 * @param PageIdentity $source
224 * @param PageIdentity $destination
225 * @param string|null $timestamp
226 * @return MergeHistory
228 public function newMergeHistory(
229 PageIdentity $source,
230 PageIdentity $destination,
231 ?string $timestamp = null
232 ): MergeHistory {
233 return new MergeHistory(
234 $source,
235 $destination,
236 $timestamp,
237 $this->lbFactory,
238 $this->contentHandlerFactory,
239 $this->revisionStoreFactory->getRevisionStore(),
240 $this->watchedItemStore,
241 $this->spamChecker,
242 $this->hookContainer,
243 $this->wikiPageFactory,
244 $this->titleFormatter,
245 $this->titleFactory,
246 $this->linkTargetLookup,
247 $this
252 * @param Title $from
253 * @param Title $to
254 * @return MovePage
256 public function newMovePage( Title $from, Title $to ): MovePage {
257 return new MovePage(
258 $from,
259 $to,
260 new ServiceOptions( MovePage::CONSTRUCTOR_OPTIONS, $this->config ),
261 $this->lbFactory,
262 $this->namespaceInfo,
263 $this->watchedItemStore,
264 $this->repoGroup,
265 $this->contentHandlerFactory,
266 $this->revisionStoreFactory->getRevisionStore(),
267 $this->spamChecker,
268 $this->hookContainer,
269 $this->wikiPageFactory,
270 $this->userFactory,
271 $this->userEditTracker,
272 $this,
273 $this->collationFactory,
274 $this->pageUpdaterFactory,
275 $this->restrictionStore,
276 $this,
277 $this->logFormatterFactory
282 * Create a new command instance for page rollback.
284 * @param PageIdentity $page
285 * @param Authority $performer
286 * @param UserIdentity $byUser
287 * @return RollbackPage
289 public function newRollbackPage(
290 PageIdentity $page,
291 Authority $performer,
292 UserIdentity $byUser
293 ): RollbackPage {
294 return new RollbackPage(
295 new ServiceOptions( RollbackPage::CONSTRUCTOR_OPTIONS, $this->config ),
296 $this->lbFactory,
297 $this->userFactory,
298 $this->readOnlyMode,
299 $this->revisionStoreFactory->getRevisionStore(),
300 $this->titleFormatter,
301 $this->hookContainer,
302 $this->wikiPageFactory,
303 $this->actorMigration,
304 $this->actorNormalization,
305 $page,
306 $performer,
307 $byUser
312 * @inheritDoc
314 public function newUndeletePage( ProperPageIdentity $page, Authority $authority ): UndeletePage {
315 return new UndeletePage(
316 $this->hookContainer,
317 $this->jobQueueGroup,
318 $this->lbFactory,
319 $this->readOnlyMode,
320 $this->repoGroup,
321 $this->undeletePageLogger,
322 $this->revisionStoreFactory->getRevisionStoreForUndelete(),
323 $this->wikiPageFactory,
324 $this->pageUpdaterFactory,
325 $this->contentHandlerFactory,
326 $this->archivedRevisionLookup,
327 $this->namespaceInfo,
328 $this->contLangMsgTextFormatter,
329 $page,
330 $authority