MediaWiki master
DeletePageJob.php
Go to the documentation of this file.
1<?php
2
4
10
16class DeletePageJob extends Job implements GenericParameterJob {
17 public function __construct( array $params ) {
18 parent::__construct( 'deletePage', $params );
19
20 $this->title = Title::makeTitle( $params['namespace'], $params['title'] );
21 }
22
23 public function run() {
25 $ticket = $services->getDBLoadBalancerFactory()->getEmptyTransactionTicket( __METHOD__ );
26 // Failure to load the page is not job failure.
27 // A parallel deletion operation may have already completed the page deletion.
28 $wikiPage = $services->getWikiPageFactory()->newFromID( $this->params['wikiPageId'] );
29 if ( $wikiPage ) {
30 $deletePage = $services->getDeletePageFactory()->newDeletePage(
31 $wikiPage,
32 $services->getUserFactory()->newFromId( $this->params['userId'] )
33 );
34 $deletePage
35 ->setSuppress( $this->params['suppress'] )
36 ->setTags( json_decode( $this->params['tags'] ) )
37 ->setLogSubtype( $this->params['logsubtype'] )
38 ->setDeletionAttempted()
39 ->deleteInternal(
40 $wikiPage,
41 // Use a fallback for BC with queued jobs.
42 $this->params['pageRole'] ?? DeletePage::PAGE_BASE,
43 $this->params['reason'],
44 $this->getRequestId(),
45 $ticket
46 );
47 }
48 return true;
49 }
50}
51
53class_alias( DeletePageJob::class, 'DeletePageJob' );
Describe and execute a background job.
Definition Job.php:41
getRequestId()
string|null Id of the request that created this job. Follows jobs recursively, allowing to track the ...
Definition Job.php:216
array $params
Array of job parameters.
Definition Job.php:46
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
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.