MediaWiki  master
DeletePageJob.php
Go to the documentation of this file.
1 <?php
2 
5 
9 class 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 }
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:203
Job\getRequestId
getRequestId()
string|null Id of the request that created this job. Follows jobs recursively, allowing to track the ...
Definition: Job.php:252
Job\$params
array $params
Array of job parameters.
Definition: Job.php:43
DeletePageJob\__construct
__construct(array $params)
Definition: DeletePageJob.php:10
Job
Class to both describe a background job and handle jobs.
Definition: Job.php:38
DeletePageJob\run
run()
Run the job.
Definition: DeletePageJob.php:16
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:648
DeletePageJob
Class DeletePageJob.
Definition: DeletePageJob.php:9
Page\DeletePage
Definition: DeletePage.php:49
GenericParameterJob
Interface for generic jobs only uses the parameters field and are JSON serializable.
Definition: GenericParameterJob.php:31