Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
DeletePageJob | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
run | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | use MediaWiki\MediaWikiServices; |
4 | use MediaWiki\Page\DeletePage; |
5 | use MediaWiki\Title\Title; |
6 | |
7 | /** |
8 | * @newable |
9 | * @since 1.32 |
10 | * @ingroup JobQueue |
11 | */ |
12 | class DeletePageJob extends Job implements GenericParameterJob { |
13 | public function __construct( array $params ) { |
14 | parent::__construct( 'deletePage', $params ); |
15 | |
16 | $this->title = Title::makeTitle( $params['namespace'], $params['title'] ); |
17 | } |
18 | |
19 | public function run() { |
20 | $services = MediaWikiServices::getInstance(); |
21 | // Failure to load the page is not job failure. |
22 | // A parallel deletion operation may have already completed the page deletion. |
23 | $wikiPage = $services->getWikiPageFactory()->newFromID( $this->params['wikiPageId'] ); |
24 | if ( $wikiPage ) { |
25 | $deletePage = $services->getDeletePageFactory()->newDeletePage( |
26 | $wikiPage, |
27 | $services->getUserFactory()->newFromId( $this->params['userId'] ) |
28 | ); |
29 | $deletePage |
30 | ->setSuppress( $this->params['suppress'] ) |
31 | ->setTags( json_decode( $this->params['tags'] ) ) |
32 | ->setLogSubtype( $this->params['logsubtype'] ) |
33 | ->setDeletionAttempted() |
34 | ->deleteInternal( |
35 | $wikiPage, |
36 | // Use a fallback for BC with queued jobs. |
37 | $this->params['pageRole'] ?? DeletePage::PAGE_BASE, |
38 | $this->params['reason'], |
39 | $this->getRequestId() |
40 | ); |
41 | } |
42 | return true; |
43 | } |
44 | } |