| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
namespace MediaWiki\Page; |
| 23 |
|
| 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; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
class PageCommandFactory implements |
| 64 |
ContentModelChangeFactory, |
| 65 |
DeletePageFactory, |
| 66 |
MergeHistoryFactory, |
| 67 |
MovePageFactory, |
| 68 |
RollbackPageFactory, |
| 69 |
UndeletePageFactory |
| 70 |
{ |
| 71 |
|
| 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; |
| 104 |
|
| 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 |
| 138 |
) { |
| 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; |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 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 |
| 194 |
); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 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 |
| 219 |
); |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 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 |
| 248 |
); |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 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 |
| 278 |
); |
| 279 |
} |
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 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 |
| 308 |
); |
| 309 |
} |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 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 |
| 331 |
); |
| 332 |
} |
| 333 |
} |