MediaWiki REL1_39
clearInterwikiCache.php
Go to the documentation of this file.
1<?php
25
26require_once __DIR__ . '/Maintenance.php';
27
34
35 public function __construct() {
36 parent::__construct();
37 $this->addDescription( 'Clear all interwiki links for all languages from the cache' );
38 }
39
40 public function execute() {
41 $dbr = $this->getDB( DB_REPLICA );
42 $cache = ObjectCache::getLocalClusterInstance();
43 $res = $dbr->newSelectQueryBuilder()
44 ->select( 'iw_prefix' )
45 ->from( 'interwiki' )
46 ->caller( __METHOD__ )
47 ->fetchResultSet();
48 $prefixes = [];
49 foreach ( $res as $row ) {
50 $prefixes[] = $row->iw_prefix;
51 }
52
53 foreach ( $this->getConfig()->get( MainConfigNames::LocalDatabases ) as $wikiId ) {
54 $this->output( "$wikiId..." );
55 foreach ( $prefixes as $prefix ) {
56 $cache->delete( "$wikiId:interwiki:$prefix" );
57 }
58 $this->output( "done\n" );
59 }
60 }
61}
62
63$maintClass = ClearInterwikiCache::class;
64require_once RUN_MAINTENANCE_IF_MAIN;
getDB()
Maintenance script to clear the cache of interwiki prefixes for all local wikis.
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.
addDescription( $text)
Set the description text.
A class containing constants representing the names of configuration variables.
$cache
Definition mcc.php:33
const DB_REPLICA
Definition defines.php:26