Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CacheInvalidator | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
invalidate | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | /** |
3 | * This program is free software: you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation, either version 3 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ |
16 | |
17 | namespace MediaWiki\GlobalUserPage; |
18 | |
19 | use MediaWiki\MediaWikiServices; |
20 | use MediaWiki\Title\Title; |
21 | |
22 | class CacheInvalidator { |
23 | /** |
24 | * Username of the user who's userpage needs to be invalidated |
25 | * |
26 | * @var string |
27 | */ |
28 | private $username; |
29 | |
30 | /** |
31 | * Array of string options |
32 | * |
33 | * @var array |
34 | */ |
35 | private $options; |
36 | |
37 | public function __construct( $username, array $options = [] ) { |
38 | $this->username = $username; |
39 | $this->options = $options; |
40 | } |
41 | |
42 | public function invalidate() { |
43 | global $wgUseCdn, $wgUseFileCache; |
44 | |
45 | if ( !$wgUseCdn && !$wgUseFileCache && !$this->options ) { |
46 | // No CDN and no options means nothing to do! |
47 | return; |
48 | } |
49 | |
50 | MediaWikiServices::getInstance()->getJobQueueGroup()->push( new LocalJobSubmitJob( |
51 | Title::newFromText( 'User:' . $this->username ), |
52 | [ |
53 | 'username' => $this->username, |
54 | 'touch' => in_array( 'links', $this->options ), |
55 | ] |
56 | ) ); |
57 | } |
58 | } |