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.
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.
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
19 * @ingroup Maintenance
22 use MediaWiki\Maintenance\Maintenance
;
24 // @codeCoverageIgnoreStart
25 require_once __DIR__
. '/Maintenance.php';
26 // @codeCoverageIgnoreEnd
29 * Clear the cache of interwiki prefixes.
31 * @ingroup Maintenance
33 class ClearInterwikiCache
extends Maintenance
{
35 public function __construct() {
36 parent
::__construct();
37 $this->addDescription( 'Clear all interwiki links for all languages from the cache' );
40 public function execute() {
41 $lookup = $this->getServiceContainer()->getInterwikiLookup();
43 $dbr = $this->getReplicaDB();
44 $prefixes = $dbr->newSelectQueryBuilder()
45 ->select( 'iw_prefix' )
47 ->caller( __METHOD__
)
50 foreach ( $prefixes as $prefix ) {
51 $this->output( "...$prefix\n" );
52 $lookup->invalidateCache( $prefix );
54 $this->output( "done\n" );
58 // @codeCoverageIgnoreStart
59 $maintClass = ClearInterwikiCache
::class;
60 require_once RUN_MAINTENANCE_IF_MAIN
;
61 // @codeCoverageIgnoreEnd