Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
IndexArchive
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 build
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 doJob
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace CirrusSearch\Job;
4
5use CirrusSearch\Updater;
6use MediaWiki\Title\Title;
7
8/**
9 * Job to add pages to the archive index.
10 */
11class IndexArchive extends CirrusTitleJob {
12
13    public function __construct( Title $title, array $params ) {
14        parent::__construct( $title, $params );
15    }
16
17    public static function build( Title $title, string $docId, int $eventTime ): IndexArchive {
18        return new self( $title, [
19            'private_data' => true,
20            "docId" => $docId,
21            self::UPDATE_KIND => self::PAGE_CHANGE,
22            self::ROOT_EVENT_TIME => $eventTime
23        ] );
24    }
25
26    /**
27     * @return bool
28     */
29    protected function doJob() {
30        $updater = Updater::build( $this->getSearchConfig(), $this->params['cluster'] ?? null );
31        if ( $this->getSearchConfig()->get( 'CirrusSearchIndexDeletes' ) ) {
32            $updater->archivePages( [
33                [
34                    'title' => $this->title,
35                    'page' => $this->params['docId'],
36                ],
37            ] );
38        }
39
40        return true;
41    }
42
43}