MediaWiki master
DeletePageJob.php
Go to the documentation of this file.
1<?php
2
6
12class DeletePageJob extends Job implements GenericParameterJob {
13 public function __construct( array $params ) {
14 parent::__construct( 'deletePage', $params );
15
16 $this->title = Title::makeTitle( $params['namespace'], $params['title'] );
17 }
18
19 public function run() {
20 $services = MediaWikiServices::getInstance();
21 // Failure to load the page is not job failure.
22 // A parallel deletion operation may have already completed the page deletion.
23 $wikiPage = $services->getWikiPageFactory()->newFromID( $this->params['wikiPageId'] );
24 if ( $wikiPage ) {
25 $deletePage = $services->getDeletePageFactory()->newDeletePage(
26 $wikiPage,
27 $services->getUserFactory()->newFromId( $this->params['userId'] )
28 );
29 $deletePage
30 ->setSuppress( $this->params['suppress'] )
31 ->setTags( json_decode( $this->params['tags'] ) )
32 ->setLogSubtype( $this->params['logsubtype'] )
33 ->setDeletionAttempted()
34 ->deleteInternal(
35 $wikiPage,
36 // Use a fallback for BC with queued jobs.
37 $this->params['pageRole'] ?? DeletePage::PAGE_BASE,
38 $this->params['reason'],
39 $this->getRequestId()
40 );
41 }
42 return true;
43 }
44}
array $params
The job parameters.
__construct(array $params)
run()
Run the job.
Describe and execute a background job.
Definition Job.php:40
getRequestId()
string|null Id of the request that created this job. Follows jobs recursively, allowing to track the ...
Definition Job.php:215
Service locator for MediaWiki core services.
Backend logic for performing a page delete action.
Represents a title within MediaWiki.
Definition Title.php:78
Interface for generic jobs only uses the parameters field and are JSON serializable.