Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
DeleteArchive | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
doJob | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace CirrusSearch\Job; |
4 | |
5 | use CirrusSearch\Connection; |
6 | use CirrusSearch\Updater; |
7 | use Title; |
8 | |
9 | /** |
10 | * Job wrapper for deleting pages from archive. |
11 | */ |
12 | class DeleteArchive extends CirrusTitleJob { |
13 | public function __construct( Title $title, array $params ) { |
14 | // While the delete is not itself private, it can only fail on clusters |
15 | // without private data as the index does not exist. |
16 | parent::__construct( $title, [ 'private_data' => true ] + $params ); |
17 | |
18 | // Don't remove dupes since we do checks that may return different results |
19 | // Also, deletes are idempotent so it's no problem if we delete twice. |
20 | $this->removeDuplicates = false; |
21 | } |
22 | |
23 | /** |
24 | * @return bool |
25 | */ |
26 | protected function doJob() { |
27 | $archive = new \PageArchive( $this->title ); |
28 | $docs = $this->params['docIds']; |
29 | |
30 | // Remove page IDs that still have archived revs |
31 | foreach ( $archive->listRevisions() as $rev ) { |
32 | unset( $docs[$rev->ar_page_id] ); |
33 | } |
34 | |
35 | if ( empty( $docs ) ) { |
36 | // If we have more deleted instances of the same title, no need to bother. |
37 | return true; |
38 | } |
39 | |
40 | $updater = Updater::build( $this->getSearchConfig(), $this->params['cluster'] ?? null ); |
41 | $updater->deletePages( |
42 | [ $this->title ], |
43 | array_keys( $docs ), |
44 | Connection::ARCHIVE_INDEX_SUFFIX, |
45 | [ 'private_data' => true ] |
46 | ); |
47 | |
48 | return true; |
49 | } |
50 | } |