MediaWiki master
clearInterwikiCache.php
Go to the documentation of this file.
1<?php
22// @codeCoverageIgnoreStart
23require_once __DIR__ . '/Maintenance.php';
24// @codeCoverageIgnoreEnd
25
32
33 public function __construct() {
34 parent::__construct();
35 $this->addDescription( 'Clear all interwiki links for all languages from the cache' );
36 }
37
38 public function execute() {
39 $lookup = $this->getServiceContainer()->getInterwikiLookup();
40
41 $dbr = $this->getReplicaDB();
42 $prefixes = $dbr->newSelectQueryBuilder()
43 ->select( 'iw_prefix' )
44 ->from( 'interwiki' )
45 ->caller( __METHOD__ )
46 ->fetchFieldValues();
47
48 foreach ( $prefixes as $prefix ) {
49 $this->output( "...$prefix\n" );
50 $lookup->invalidateCache( $prefix );
51 }
52 $this->output( "done\n" );
53 }
54}
55
56// @codeCoverageIgnoreStart
57$maintClass = ClearInterwikiCache::class;
58require_once RUN_MAINTENANCE_IF_MAIN;
59// @codeCoverageIgnoreEnd
Clear the cache of interwiki prefixes.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.