Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ClearInterwikiCache
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 * @ingroup Maintenance
6 */
7
8use MediaWiki\Maintenance\Maintenance;
9
10// @codeCoverageIgnoreStart
11require_once __DIR__ . '/Maintenance.php';
12// @codeCoverageIgnoreEnd
13
14/**
15 * Clear the cache of interwiki prefixes.
16 *
17 * @ingroup Maintenance
18 */
19class ClearInterwikiCache extends Maintenance {
20
21    public function __construct() {
22        parent::__construct();
23        $this->addDescription( 'Clear all interwiki links for all languages from the cache' );
24    }
25
26    public function execute() {
27        $lookup = $this->getServiceContainer()->getInterwikiLookup();
28
29        $dbr = $this->getReplicaDB();
30        $prefixes = $dbr->newSelectQueryBuilder()
31            ->select( 'iw_prefix' )
32            ->from( 'interwiki' )
33            ->caller( __METHOD__ )
34            ->fetchFieldValues();
35
36        foreach ( $prefixes as $prefix ) {
37            $this->output( "...$prefix\n" );
38            $lookup->invalidateCache( $prefix );
39        }
40        $this->output( "done\n" );
41    }
42}
43
44// @codeCoverageIgnoreStart
45$maintClass = ClearInterwikiCache::class;
46require_once RUN_MAINTENANCE_IF_MAIN;
47// @codeCoverageIgnoreEnd