MediaWiki master
clearInterwikiCache.php
Go to the documentation of this file.
1<?php
23
24// @codeCoverageIgnoreStart
25require_once __DIR__ . '/Maintenance.php';
26// @codeCoverageIgnoreEnd
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 $lookup = $this->getServiceContainer()->getInterwikiLookup();
42
43 $dbr = $this->getReplicaDB();
44 $prefixes = $dbr->newSelectQueryBuilder()
45 ->select( 'iw_prefix' )
46 ->from( 'interwiki' )
47 ->caller( __METHOD__ )
48 ->fetchFieldValues();
49
50 foreach ( $prefixes as $prefix ) {
51 $this->output( "...$prefix\n" );
52 $lookup->invalidateCache( $prefix );
53 }
54 $this->output( "done\n" );
55 }
56}
57
58// @codeCoverageIgnoreStart
59$maintClass = ClearInterwikiCache::class;
60require_once RUN_MAINTENANCE_IF_MAIN;
61// @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.