Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| DeletePages | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| build | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| doJob | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\Job; |
| 4 | |
| 5 | use CirrusSearch\Updater; |
| 6 | use MediaWiki\Title\Title; |
| 7 | |
| 8 | /** |
| 9 | * Job wrapper around Updater::deletePages. If indexSuffix parameter is |
| 10 | * specified then only deletes from indices with a matching suffix. |
| 11 | * |
| 12 | * @license GPL-2.0-or-later |
| 13 | */ |
| 14 | class DeletePages extends CirrusTitleJob { |
| 15 | public function __construct( Title $title, array $params ) { |
| 16 | parent::__construct( $title, $params ); |
| 17 | |
| 18 | // This is one of the cheapest jobs we have. Plus I'm reasonably |
| 19 | // paranoid about deletions so I'd rather delete things extra times |
| 20 | // if something actually requested it. |
| 21 | $this->removeDuplicates = false; |
| 22 | } |
| 23 | |
| 24 | public static function build( Title $title, string $docId, int $eventTime ): DeletePages { |
| 25 | return new self( $title, [ |
| 26 | "docId" => $docId, |
| 27 | self::UPDATE_KIND => self::PAGE_CHANGE, |
| 28 | self::ROOT_EVENT_TIME => $eventTime |
| 29 | ] ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @return bool |
| 34 | */ |
| 35 | protected function doJob() { |
| 36 | $updater = Updater::build( $this->getSearchConfig(), $this->params['cluster'] ?? null ); |
| 37 | // BC for rename from indexType to indexSuffix |
| 38 | $indexSuffix = $this->params['indexSuffix'] ?? $this->params['indexType'] ?? null; |
| 39 | $updater->deletePages( [ $this->title ], [ $this->params['docId'] ], $indexSuffix ); |
| 40 | |
| 41 | return true; |
| 42 | } |
| 43 | } |