MediaWiki master
DeletePageJob.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Page;
4
9
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
24 public function run() {
26 $ticket = $services->getDBLoadBalancerFactory()->getEmptyTransactionTicket( __METHOD__ );
27 // Failure to load the page is not job failure.
28 // A parallel deletion operation may have already completed the page deletion.
29 $wikiPage = $services->getWikiPageFactory()->newFromID( $this->params['wikiPageId'] );
30 if ( $wikiPage ) {
31 $deletePage = $services->getDeletePageFactory()->newDeletePage(
32 $wikiPage,
33 $services->getUserFactory()->newFromId( $this->params['userId'] )
34 );
35 $deletePage
36 ->setSuppress( $this->params['suppress'] )
37 ->setTags( json_decode( $this->params['tags'] ) )
38 ->setLogSubtype( $this->params['logsubtype'] )
39 ->setDeletionAttempted()
40 ->deleteInternal(
41 $wikiPage,
42 // Use a fallback for BC with queued jobs.
43 $this->params['pageRole'] ?? DeletePage::PAGE_BASE,
44 $this->params['reason'],
45 $this->getRequestId(),
46 $ticket
47 );
48 }
49 return true;
50 }
51}
52
54class_alias( DeletePageJob::class, 'DeletePageJob' );
55
57class_alias( DeletePageJob::class, 'MediaWiki\JobQueue\Jobs\DeletePageJob' );
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
Describe and execute a background job.
Definition Job.php:28
getRequestId()
string|null Id of the request that created this job. Follows jobs recursively, allowing to track the ...
Definition Job.php:203
array $params
Array of job parameters.
Definition Job.php:33
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
run()
Run the job.If this method returns false or completes exceptionally, the job runner will retry execut...
const PAGE_BASE
Constants used for the return value of getSuccessfulDeletionsIDs() and deletionsWereScheduled()
Represents a title within MediaWiki.
Definition Title.php:69
Interface for generic jobs only uses the parameters field and are JSON serializable.