2009-09-12 00:05:04 +00:00
|
|
|
<?php
|
2009-12-04 14:57:21 +00:00
|
|
|
/**
|
2012-07-08 20:47:27 +00:00
|
|
|
* Delete self-references to $wgServer from the externallinks table.
|
2009-12-04 14:57:21 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2012-07-08 20:47:27 +00:00
|
|
|
* @file
|
2009-12-04 14:57:21 +00:00
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2009-09-12 00:02:57 +00:00
|
|
|
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2009-12-04 14:57:21 +00:00
|
|
|
|
2012-07-08 20:47:27 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script that deletes self-references to $wgServer
|
|
|
|
|
* from the externallinks table.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2009-12-04 14:57:21 +00:00
|
|
|
class DeleteSelfExternals extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( 'Delete self-references to $wgServer from externallinks' );
|
2017-11-04 23:10:06 +00:00
|
|
|
$this->setBatchSize( 1000 );
|
2009-12-04 14:57:21 +00:00
|
|
|
}
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2009-12-04 14:57:21 +00:00
|
|
|
public function execute() {
|
|
|
|
|
global $wgServer;
|
|
|
|
|
$this->output( "Deleting self externals from $wgServer\n" );
|
2015-12-31 00:07:37 +00:00
|
|
|
$db = $this->getDB( DB_MASTER );
|
2010-05-22 16:50:39 +00:00
|
|
|
while ( 1 ) {
|
2011-04-20 00:12:06 +00:00
|
|
|
wfWaitForSlaves();
|
2015-12-22 08:51:42 +00:00
|
|
|
$this->commitTransaction( $db, __METHOD__ );
|
2010-05-22 16:50:39 +00:00
|
|
|
$q = $db->limitResult( "DELETE /* deleteSelfExternals */ FROM externallinks WHERE el_to"
|
2009-12-04 14:57:21 +00:00
|
|
|
. $db->buildLike( $wgServer . '/', $db->anyString() ), $this->mBatchSize );
|
|
|
|
|
$this->output( "Deleting a batch\n" );
|
2010-05-22 16:50:39 +00:00
|
|
|
$db->query( $q );
|
2013-04-18 18:48:44 +00:00
|
|
|
if ( !$db->affectedRows() ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-12-04 14:57:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-09-12 00:02:57 +00:00
|
|
|
}
|
2009-12-04 14:57:21 +00:00
|
|
|
|
|
|
|
|
$maintClass = "DeleteSelfExternals";
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|