Merge "Remove temporary parameter"

This commit is contained in:
jenkins-bot 2020-11-18 09:09:02 +00:00 committed by Gerrit Code Review
commit 3158a7ebc7
2 changed files with 9 additions and 21 deletions

View file

@ -210,11 +210,9 @@ class AbuseFilter {
/**
* @param string[] $filters
* @param bool $legacy TEMPORARY whether to get data in legacy format
* @return (string|array)[][][]|array[][]
* @phan-return array<string,array<string,array{action:string,parameters:string[]}>>|array[][]
* @return array[][]
*/
public static function getConsequencesForFilters( $filters, $legacy = true ) {
public static function getConsequencesForFilters( $filters ) {
$globalFilters = [];
$localFilters = [];
@ -234,15 +232,14 @@ class AbuseFilter {
$consequences = [];
if ( count( $localFilters ) ) {
$consequences = self::loadConsequencesFromDB( $dbr, $localFilters, '', $legacy );
$consequences = self::loadConsequencesFromDB( $dbr, $localFilters, '' );
}
if ( count( $globalFilters ) ) {
$consequences += self::loadConsequencesFromDB(
AbuseFilterServices::getCentralDBManager()->getConnection( DB_REPLICA ),
$globalFilters,
self::GLOBAL_FILTER_PREFIX,
$legacy
self::GLOBAL_FILTER_PREFIX
);
}
@ -253,16 +250,9 @@ class AbuseFilter {
* @param IDatabase $dbr
* @param string[] $filters
* @param string $prefix
* @param bool $legacy TEMPORARY whether to get data in legacy format
* @return (string|array)[][][]|array[][]
* @phan-return array<string,array<string,array{action:string,parameters:string[]}>>|array[][]
* @return array[][]
*/
private static function loadConsequencesFromDB(
IDatabase $dbr,
$filters,
$prefix = '',
$legacy = true
) {
private static function loadConsequencesFromDB( IDatabase $dbr, $filters, $prefix = '' ) {
$actionsByFilter = [];
foreach ( $filters as $filter ) {
$actionsByFilter[$prefix . $filter] = [];
@ -295,10 +285,8 @@ class AbuseFilter {
// We probably got a NULL, as it's a LEFT JOIN. Don't add it.
continue;
} else {
$params = array_filter( explode( "\n", $row->afa_parameters ) );
$actionsByFilter[$prefix . $row->afa_filter][$row->afa_consequence] = $legacy
? [ 'action' => $row->afa_consequence, 'parameters' => $params ]
: $params;
$actionsByFilter[$prefix . $row->afa_filter][$row->afa_consequence] =
array_filter( explode( "\n", $row->afa_parameters ) );
}
}

View file

@ -447,7 +447,7 @@ class AbuseFilterRunner {
global $wgAbuseFilterLocallyDisabledGlobalActions,
$wgAbuseFilterBlockDuration, $wgAbuseFilterAnonBlockDuration;
$actionsByFilter = AbuseFilter::getConsequencesForFilters( $filters, false );
$actionsByFilter = AbuseFilter::getConsequencesForFilters( $filters );
$actionsTaken = array_fill_keys( $filters, [] );
$messages = [];