MediaWiki  master
clearInterwikiCache.php
Go to the documentation of this file.
1 <?php
23 
24 require_once __DIR__ . '/Maintenance.php';
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 = MediaWikiServices::getInstance()->getInterwikiLookup();
40 
41  $dbr = $this->getDB( DB_REPLICA );
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 $maintClass = ClearInterwikiCache::class;
57 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.
addDescription( $text)
Set the description text.
Service locator for MediaWiki core services.
const DB_REPLICA
Definition: defines.php:26