Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CirrusTitleJob | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getSearchConfig | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace CirrusSearch\Job; |
4 | |
5 | use CirrusSearch\SearchConfig; |
6 | use Job; |
7 | use MediaWiki\MediaWikiServices; |
8 | use Title; |
9 | |
10 | /** |
11 | * CirrusSearch Job that is bound to a Title |
12 | * |
13 | * This program is free software; you can redistribute it and/or modify |
14 | * it under the terms of the GNU General Public License as published by |
15 | * the Free Software Foundation; either version 2 of the License, or |
16 | * (at your option) any later version. |
17 | * |
18 | * This program is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | * GNU General Public License for more details. |
22 | * |
23 | * You should have received a copy of the GNU General Public License along |
24 | * with this program; if not, write to the Free Software Foundation, Inc., |
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
26 | * http://www.gnu.org/copyleft/gpl.html |
27 | */ |
28 | abstract class CirrusTitleJob extends Job { |
29 | use JobTraits; |
30 | |
31 | /** |
32 | * @var SearchConfig|null (lazy loaded by getSearchConfig()) |
33 | */ |
34 | private $searchConfig; |
35 | |
36 | /** |
37 | * @param Title $title |
38 | * @param array $params |
39 | */ |
40 | public function __construct( $title, $params ) { |
41 | $params += [ 'cluster' => null ]; |
42 | // eg: DeletePages -> cirrusSearchDeletePages |
43 | $jobName = self::buildJobName( static::class ); |
44 | |
45 | parent::__construct( $jobName, $title, $params ); |
46 | |
47 | // All CirrusSearch jobs are reasonably expensive. Most involve parsing and it |
48 | // is ok to remove duplicate _unclaimed_ cirrus jobs. Once a cirrus job is claimed |
49 | // it can't be deduplicated or else the search index will end up with out of date |
50 | // data. Luckily, this is how the JobQueue implementations work. |
51 | $this->removeDuplicates = true; |
52 | } |
53 | |
54 | /** |
55 | * @return SearchConfig |
56 | */ |
57 | public function getSearchConfig(): SearchConfig { |
58 | if ( $this->searchConfig === null ) { |
59 | $this->searchConfig = MediaWikiServices::getInstance() |
60 | ->getConfigFactory() |
61 | ->makeConfig( 'CirrusSearch' ); |
62 | } |
63 | return $this->searchConfig; |
64 | } |
65 | } |