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 $ticket = $services->getDBLoadBalancerFactory()->getEmptyTransactionTicket( __METHOD__ );
22 // Failure to load the page is not job failure.
23 // A parallel deletion operation may have already completed the page deletion.
24 $wikiPage = $services->getWikiPageFactory()->newFromID( $this->params['wikiPageId'] );
25 if ( $wikiPage ) {
26 $deletePage = $services->getDeletePageFactory()->newDeletePage(
27 $wikiPage,
28 $services->getUserFactory()->newFromId( $this->params['userId'] )
29 );
30 $deletePage
31 ->setSuppress( $this->params['suppress'] )
32 ->setTags( json_decode( $this->params['tags'] ) )
33 ->setLogSubtype( $this->params['logsubtype'] )
34 ->setDeletionAttempted()
35 ->deleteInternal(
36 $wikiPage,
37 // Use a fallback for BC with queued jobs.
38 $this->params['pageRole'] ?? DeletePage::PAGE_BASE,
39 $this->params['reason'],
40 $this->getRequestId(),
41 $ticket
42 );
43 }
44 return true;
45 }
46}
array $params
The job parameters.
__construct(array $params)
run()
Run the job.
Describe and execute a background job.
Definition Job.php:38
getRequestId()
string|null Id of the request that created this job. Follows jobs recursively, allowing to track the ...
Definition Job.php:212
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.