MediaWiki  master
DeletePageJob.php
Go to the documentation of this file.
1 <?php
2 
4 
8 class DeletePageJob extends Job implements GenericParameterJob {
9  public function __construct( array $params ) {
10  parent::__construct( 'deletePage', $params );
11 
12  $this->title = Title::makeTitle( $params['namespace'], $params['title'] );
13  }
14 
15  public function run() {
16  // Failure to load the page is not job failure.
17  // A parallel deletion operation may have already completed the page deletion.
18  $wikiPage = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromID( $this->params['wikiPageId'] );
19  if ( $wikiPage ) {
20  $wikiPage->doDeleteArticleBatched(
21  $this->params['reason'],
22  $this->params['suppress'],
23  User::newFromId( $this->params['userId'] ),
24  json_decode( $this->params['tags'] ),
25  $this->params['logsubtype'],
26  false,
27  $this->getRequestId() );
28  }
29  return true;
30  }
31 }
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:647
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:193
Job\getRequestId
getRequestId()
string|null Id of the request that created this job. Follows jobs recursively, allowing to track the ...
Definition: Job.php:251
Job\$params
array $params
Array of job parameters.
Definition: Job.php:42
DeletePageJob\__construct
__construct(array $params)
Definition: DeletePageJob.php:9
Job
Class to both describe a background job and handle jobs.
Definition: Job.php:37
DeletePageJob\run
run()
Run the job.
Definition: DeletePageJob.php:15
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:651
DeletePageJob
Class DeletePageJob.
Definition: DeletePageJob.php:8
GenericParameterJob
Interface for generic jobs only uses the parameters field and are JSON serializable.
Definition: GenericParameterJob.php:31