Merge maintenance-work branch:
[lhc/web/wiklou.git] / maintenance / clear_interwiki_cache.php
1 <?php
2 /**
3 * This script is used to clear the interwiki links for ALL languages in
4 * memcached.
5 *
6 * @ingroup Maintenance
7 */
8
9 require_once( "Maintenance.php" );
10
11 class ClearInterwikiCache extends Maintenance {
12
13 public function __construct() {
14 parent::__construct();
15 $this->mDescription = "Clear all interwiki links for all languages from the cache";
16 }
17
18 public function execute() {
19 global $wgLocalDatabases;
20 $dbr = wfGetDB( DB_SLAVE );
21 $res = $dbr->select( 'interwiki', array( 'iw_prefix' ), false );
22 $prefixes = array();
23 while ( $row = $dbr->fetchObject( $res ) ) {
24 $prefixes[] = $row->iw_prefix;
25 }
26
27 foreach ( $wgLocalDatabases as $db ) {
28 $this->output( "$db..." );
29 foreach ( $prefixes as $prefix ) {
30 $wgMemc->delete("$db:interwiki:$prefix");
31 }
32 $this->output( "done\n" );
33 }
34 }
35 }
36
37 $maintClass = "ClearInterwikiCache";
38 require_once( DO_MAINTENANCE );