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