Merge maintenance-work branch:
[lhc/web/wiklou.git] / maintenance / clear_interwiki_cache.php
index ce15477..88d08ba 100644 (file)
@@ -3,25 +3,36 @@
  * This script is used to clear the interwiki links for ALL languages in
  * memcached.
  *
- * @file
  * @ingroup Maintenance
  */
 
-/** */
-require_once('commandLine.inc');
+require_once( "Maintenance.php" );
 
-$dbr = wfGetDB( DB_SLAVE );
-$res = $dbr->select( 'interwiki', array( 'iw_prefix' ), false );
-$prefixes = array();
-while ( $row = $dbr->fetchObject( $res ) ) {
-       $prefixes[] = $row->iw_prefix;
-}
+class ClearInterwikiCache extends Maintenance {
+
+       public function __construct() {
+               parent::__construct();
+               $this->mDescription = "Clear all interwiki links for all languages from the cache";
+       }
+
+       public function execute() {
+               global $wgLocalDatabases;
+               $dbr = wfGetDB( DB_SLAVE );
+               $res = $dbr->select( 'interwiki', array( 'iw_prefix' ), false );
+               $prefixes = array();
+               while ( $row = $dbr->fetchObject( $res ) ) {
+                       $prefixes[] = $row->iw_prefix;
+               }
 
-foreach ( $wgLocalDatabases as $db ) {
-       print "$db ";
-       foreach ( $prefixes as $prefix ) {
-               $wgMemc->delete("$db:interwiki:$prefix");
+               foreach ( $wgLocalDatabases as $db ) {
+                       $this->output( "$db..." );
+                       foreach ( $prefixes as $prefix ) {
+                               $wgMemc->delete("$db:interwiki:$prefix");
+                       }
+                       $this->output( "done\n" );
+               }
        }
 }
-print "\n";
 
+$maintClass = "ClearInterwikiCache";
+require_once( DO_MAINTENANCE );