34 $server = $this->
getConfig()->get( MainConfigNames::Server );
37 $this->
fatalError(
'Could not parse $wgServer' );
40 $this->
output(
"Deleting self externals from $server\n" );
42 ExternalLinksTable::VIRTUAL_DOMAIN
47 $host = $bits[
'host'];
48 if ( isset( $bits[
'port'] ) ) {
49 $host .=
':' . $bits[
'port'];
51 if ( $bits[
'scheme'] !=
'' ) {
52 $conds = [ LinkFilter::getQueryConditions( $host, [
'protocol' => $bits[
'scheme'] .
'://' ] ) ];
55 LinkFilter::getQueryConditions( $host, [
'protocol' =>
'http://' ] ),
56 LinkFilter::getQueryConditions( $host, [
'protocol' =>
'https://' ] ),
63 $conds = array_map(
static function ( $cond ) use ( $db ) {
64 return $db->andExpr( $cond );
65 }, array_filter( $conds ) );
66 $domainExpr = $db->orExpr( $conds );
72 $this->
output(
"Deleting self-externals with el_id $batchStart to $batchEnd\n" );
74 $db->newDeleteQueryBuilder()
75 ->deleteFrom(
'externallinks' )
76 ->where( $domainExpr )
77 ->andWhere( $db->expr(
'el_id',
'>', $batchStart ) )
78 ->andWhere( $db->expr(
'el_id',
'<=', $batchEnd ) )
79 ->caller( __METHOD__ )
81 $rowsDeletedInThisBatch = $db->affectedRows();
82 $totalRows += $rowsDeletedInThisBatch;
87 }
while ( $rowsDeletedInThisBatch );
89 $this->
output(
"done; deleted $totalRows rows\n" );