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 | private string $username; |
27 | |
28 | /** |
29 | * Array of string options |
30 | */ |
31 | private array $options; |
32 | |
33 | public function __construct( string $username, array $options = [] ) { |
34 | $this->username = $username; |
35 | $this->options = $options; |
36 | } |
37 | |
38 | public function invalidate(): void { |
39 | global $wgUseCdn, $wgUseFileCache; |
40 | |
41 | if ( !$wgUseCdn && !$wgUseFileCache && !$this->options ) { |
42 | // No CDN and no options means nothing to do! |
43 | return; |
44 | } |
45 | |
46 | MediaWikiServices::getInstance()->getJobQueueGroup()->push( new LocalJobSubmitJob( |
47 | Title::newFromText( 'User:' . $this->username ), |
48 | [ |
49 | 'username' => $this->username, |
50 | 'touch' => in_array( 'links', $this->options ), |
51 | ] |
52 | ) ); |
53 | } |
54 | } |