47 $server = $this->
getConfig()->get( MainConfigNames::Server );
50 $this->
fatalError(
'Could not parse $wgServer' );
53 $this->
output(
"Deleting self externals from $server\n" );
58 $host = $bits[
'host'];
59 if ( isset( $bits[
'port'] ) ) {
60 $host .=
':' . $bits[
'port'];
62 if ( $bits[
'scheme'] !=
'' ) {
63 $conds = [ LinkFilter::getQueryConditions( $host, [
'protocol' => $bits[
'scheme'] .
'://' ] ) ];
66 LinkFilter::getQueryConditions( $host, [
'protocol' =>
'http://' ] ),
67 LinkFilter::getQueryConditions( $host, [
'protocol' =>
'https://' ] ),
74 $conds = array_map(
static function ( $cond ) use ( $db ) {
75 return $db->andExpr( $cond );
76 }, array_filter( $conds ) );
77 $domainExpr = $db->orExpr( $conds );
83 $this->
output(
"Deleting self-externals with el_id $batchStart to $batchEnd\n" );
85 $db->newDeleteQueryBuilder()
86 ->deleteFrom(
'externallinks' )
87 ->where( $domainExpr )
88 ->andWhere( $db->expr(
'el_id',
'>', $batchStart ) )
89 ->andWhere( $db->expr(
'el_id',
'<=', $batchEnd ) )
90 ->caller( __METHOD__ )
92 $rowsDeletedInThisBatch = $db->affectedRows();
93 $totalRows += $rowsDeletedInThisBatch;
98 }
while ( $rowsDeletedInThisBatch );
100 $this->
output(
"done; deleted $totalRows rows\n" );