MediaWiki  master
clearInterwikiCache.php
Go to the documentation of this file.
1 <?php
22 require_once __DIR__ . '/Maintenance.php';
23 
30 
31  public function __construct() {
32  parent::__construct();
33  $this->addDescription( 'Clear all interwiki links for all languages from the cache' );
34  }
35 
36  public function execute() {
37  $lookup = $this->getServiceContainer()->getInterwikiLookup();
38 
39  $dbr = $this->getDB( DB_REPLICA );
40  $prefixes = $dbr->newSelectQueryBuilder()
41  ->select( 'iw_prefix' )
42  ->from( 'interwiki' )
43  ->caller( __METHOD__ )
44  ->fetchFieldValues();
45 
46  foreach ( $prefixes as $prefix ) {
47  $this->output( "...$prefix\n" );
48  $lookup->invalidateCache( $prefix );
49  }
50  $this->output( "done\n" );
51  }
52 }
53 
54 $maintClass = ClearInterwikiCache::class;
55 require_once RUN_MAINTENANCE_IF_MAIN;
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...
Definition: Maintenance.php:66
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
output( $out, $channel=null)
Throw some output to the user.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.
const DB_REPLICA
Definition: defines.php:26