MediaWiki  REL1_19
deleteSelfExternals.php
Go to the documentation of this file.
00001 <?php
00027 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
00028 
00029 
00030 class DeleteSelfExternals extends Maintenance {
00031         public function __construct() {
00032                 parent::__construct();
00033                 $this->mDescription = 'Delete self-references to $wgServer from externallinks';
00034                 $this->mBatchSize = 1000;
00035         }
00036 
00037         public function execute() {
00038                 global $wgServer;
00039                 $this->output( "Deleting self externals from $wgServer\n" );
00040                 $db = wfGetDB( DB_MASTER );
00041                 while ( 1 ) {
00042                         wfWaitForSlaves();
00043                         $db->commit();
00044                         $q = $db->limitResult( "DELETE /* deleteSelfExternals */ FROM externallinks WHERE el_to"
00045                                 . $db->buildLike( $wgServer . '/', $db->anyString() ), $this->mBatchSize );
00046                         $this->output( "Deleting a batch\n" );
00047                         $db->query( $q );
00048                         if ( !$db->affectedRows() ) return;
00049                 }
00050         }
00051 }
00052 
00053 $maintClass = "DeleteSelfExternals";
00054 require_once( RUN_MAINTENANCE_IF_MAIN );