Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
DeletePages
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
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
 doJob
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace CirrusSearch\Job;
4
5use CirrusSearch\Updater;
6use 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    /**
38     * @return bool
39     */
40    protected function doJob() {
41        $updater = Updater::build( $this->getSearchConfig(), $this->params['cluster'] ?? null );
42        // BC for rename from indexType to indexSuffix
43        $indexSuffix = $this->params['indexSuffix'] ?? $this->params['indexType'] ?? null;
44        $updater->deletePages( [ $this->title ], [ $this->params['docId'] ], $indexSuffix );
45
46        if ( $this->getSearchConfig()->get( 'CirrusSearchIndexDeletes' ) ) {
47            $updater->archivePages( [
48                [
49                    'title' => $this->title,
50                    'page' => $this->params['docId'],
51                ],
52            ] );
53        }
54
55        return true;
56    }
57}