Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CirrusTitleJob | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 8 |
|
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 MediaWiki\Title\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 | // TODO: move these constants to JobTraits once we support php 8.2 |
32 | public const UPDATE_KIND = 'update_kind'; |
33 | public const ROOT_EVENT_TIME = 'root_event_time'; |
34 | /** a change made to the page, new revision/delete/restore */ |
35 | public const PAGE_CHANGE = 'page_change'; |
36 | /** a change that could possibly change the rendered output of the page */ |
37 | public const PAGE_REFRESH = 'page_refresh'; |
38 | /** a change emitted when detecting a visibility change on a past revision |
39 | * theoretically not needed but is being triggered out of caution as generally visibility changes |
40 | * occur to hide harmful content. |
41 | */ |
42 | public const VISIBILITY_CHANGE = "visibility_change"; |
43 | /** |
44 | * Change issued from the saneitizer, either a fixup or a forced update |
45 | */ |
46 | public const SANEITIZER = "saneitizer"; |
47 | |
48 | /** param key to store the target elastic cluster */ |
49 | public const CLUSTER = 'cluster'; |
50 | |
51 | /** |
52 | * @var SearchConfig|null (lazy loaded by getSearchConfig()) |
53 | */ |
54 | private $searchConfig; |
55 | |
56 | /** |
57 | * @param Title $title |
58 | * @param array $params |
59 | */ |
60 | public function __construct( $title, $params ) { |
61 | $params += [ |
62 | self::CLUSTER => null, |
63 | self::UPDATE_KIND => 'unknown', |
64 | self::ROOT_EVENT_TIME => null |
65 | ]; |
66 | // eg: DeletePages -> cirrusSearchDeletePages |
67 | $jobName = self::buildJobName( static::class ); |
68 | |
69 | parent::__construct( $jobName, $title, $params ); |
70 | |
71 | // All CirrusSearch jobs are reasonably expensive. Most involve parsing and it |
72 | // is ok to remove duplicate _unclaimed_ cirrus jobs. Once a cirrus job is claimed |
73 | // it can't be deduplicated or else the search index will end up with out of date |
74 | // data. Luckily, this is how the JobQueue implementations work. |
75 | $this->removeDuplicates = true; |
76 | } |
77 | |
78 | /** |
79 | * @return SearchConfig |
80 | */ |
81 | public function getSearchConfig(): SearchConfig { |
82 | if ( $this->searchConfig === null ) { |
83 | $this->searchConfig = MediaWikiServices::getInstance() |
84 | ->getConfigFactory() |
85 | ->makeConfig( 'CirrusSearch' ); |
86 | } |
87 | return $this->searchConfig; |
88 | } |
89 | } |