MediaWiki  master
DeletePageJob.php
Go to the documentation of this file.
1 <?php
2 
5 
11 class DeletePageJob extends Job implements GenericParameterJob {
12  public function __construct( array $params ) {
13  parent::__construct( 'deletePage', $params );
14 
15  $this->title = Title::makeTitle( $params['namespace'], $params['title'] );
16  }
17 
18  public function run() {
19  $services = MediaWikiServices::getInstance();
20  // Failure to load the page is not job failure.
21  // A parallel deletion operation may have already completed the page deletion.
22  $wikiPage = $services->getWikiPageFactory()->newFromID( $this->params['wikiPageId'] );
23  if ( $wikiPage ) {
24  $deletePage = $services->getDeletePageFactory()->newDeletePage(
25  $wikiPage,
26  $services->getUserFactory()->newFromId( $this->params['userId'] )
27  );
28  $deletePage
29  ->setSuppress( $this->params['suppress'] )
30  ->setTags( json_decode( $this->params['tags'] ) )
31  ->setLogSubtype( $this->params['logsubtype'] )
32  ->setDeletionAttempted()
33  ->deleteInternal(
34  $wikiPage,
35  // Use a fallback for BC with queued jobs.
36  $this->params['pageRole'] ?? DeletePage::PAGE_BASE,
37  $this->params['reason'],
38  $this->getRequestId()
39  );
40  }
41  return true;
42  }
43 }
__construct(array $params)
run()
Run the job.
Class to both describe a background job and handle jobs.
Definition: Job.php:39
array $params
Array of job parameters.
Definition: Job.php:44
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.
Definition: DeletePage.php:52
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:641
Interface for generic jobs only uses the parameters field and are JSON serializable.