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