Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / jobqueue / jobs / DeletePageJob.php
blobf4e1feaf172f16e854fa524d59be9a9453524139
1 <?php
3 use MediaWiki\MediaWikiServices;
4 use MediaWiki\Page\DeletePage;
5 use MediaWiki\Title\Title;
7 /**
8 * @newable
9 * @since 1.32
10 * @ingroup JobQueue
12 class DeletePageJob extends Job implements GenericParameterJob {
13 public function __construct( array $params ) {
14 parent::__construct( 'deletePage', $params );
16 $this->title = Title::makeTitle( $params['namespace'], $params['title'] );
19 public function run() {
20 $services = MediaWikiServices::getInstance();
21 $ticket = $services->getDBLoadBalancerFactory()->getEmptyTransactionTicket( __METHOD__ );
22 // Failure to load the page is not job failure.
23 // A parallel deletion operation may have already completed the page deletion.
24 $wikiPage = $services->getWikiPageFactory()->newFromID( $this->params['wikiPageId'] );
25 if ( $wikiPage ) {
26 $deletePage = $services->getDeletePageFactory()->newDeletePage(
27 $wikiPage,
28 $services->getUserFactory()->newFromId( $this->params['userId'] )
30 $deletePage
31 ->setSuppress( $this->params['suppress'] )
32 ->setTags( json_decode( $this->params['tags'] ) )
33 ->setLogSubtype( $this->params['logsubtype'] )
34 ->setDeletionAttempted()
35 ->deleteInternal(
36 $wikiPage,
37 // Use a fallback for BC with queued jobs.
38 $this->params['pageRole'] ?? DeletePage::PAGE_BASE,
39 $this->params['reason'],
40 $this->getRequestId(),
41 $ticket
44 return true;