Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
ClearInterwikiCache | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
2 |
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 2 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 along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | * @ingroup Maintenance |
20 | */ |
21 | |
22 | use MediaWiki\Maintenance\Maintenance; |
23 | |
24 | // @codeCoverageIgnoreStart |
25 | require_once __DIR__ . '/Maintenance.php'; |
26 | // @codeCoverageIgnoreEnd |
27 | |
28 | /** |
29 | * Clear the cache of interwiki prefixes. |
30 | * |
31 | * @ingroup Maintenance |
32 | */ |
33 | class ClearInterwikiCache extends Maintenance { |
34 | |
35 | public function __construct() { |
36 | parent::__construct(); |
37 | $this->addDescription( 'Clear all interwiki links for all languages from the cache' ); |
38 | } |
39 | |
40 | public function execute() { |
41 | $lookup = $this->getServiceContainer()->getInterwikiLookup(); |
42 | |
43 | $dbr = $this->getReplicaDB(); |
44 | $prefixes = $dbr->newSelectQueryBuilder() |
45 | ->select( 'iw_prefix' ) |
46 | ->from( 'interwiki' ) |
47 | ->caller( __METHOD__ ) |
48 | ->fetchFieldValues(); |
49 | |
50 | foreach ( $prefixes as $prefix ) { |
51 | $this->output( "...$prefix\n" ); |
52 | $lookup->invalidateCache( $prefix ); |
53 | } |
54 | $this->output( "done\n" ); |
55 | } |
56 | } |
57 | |
58 | // @codeCoverageIgnoreStart |
59 | $maintClass = ClearInterwikiCache::class; |
60 | require_once RUN_MAINTENANCE_IF_MAIN; |
61 | // @codeCoverageIgnoreEnd |