MediaWiki master
clearInterwikiCache.php
Go to the documentation of this file.
1<?php
9
10// @codeCoverageIgnoreStart
11require_once __DIR__ . '/Maintenance.php';
12// @codeCoverageIgnoreEnd
13
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
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.
getReplicaDB(string|false $virtualDomain=false)
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.