Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
DeletePages
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 build
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 doJob
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace CirrusSearch\Job;
4
5use CirrusSearch\Updater;
6use 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 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 * http://www.gnu.org/copyleft/gpl.html
26 */
27class DeletePages extends CirrusTitleJob {
28    public function __construct( Title $title, array $params ) {
29        parent::__construct( $title, $params );
30
31        // This is one of the cheapest jobs we have. Plus I'm reasonably
32        // paranoid about deletions so I'd rather delete things extra times
33        // if something actually requested it.
34        $this->removeDuplicates = false;
35    }
36
37    public static function build( Title $title, string $docId, int $eventTime ): DeletePages {
38        return new self( $title, [
39            "docId" => $docId,
40            self::UPDATE_KIND => self::PAGE_CHANGE,
41            self::ROOT_EVENT_TIME => $eventTime
42        ] );
43    }
44
45    /**
46     * @return bool
47     */
48    protected function doJob() {
49        $updater = Updater::build( $this->getSearchConfig(), $this->params['cluster'] ?? null );
50        // BC for rename from indexType to indexSuffix
51        $indexSuffix = $this->params['indexSuffix'] ?? $this->params['indexType'] ?? null;
52        $updater->deletePages( [ $this->title ], [ $this->params['docId'] ], $indexSuffix );
53
54        return true;
55    }
56}