Page MenuHomePhabricator

SearchFilters.php: Distinguish between filters which have "block" and "blockautopromote" consequences
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

Currently, --consequence="block" will return filters which have the blockautopromote consequence.

This is because we do a substring match.

Steps to reproduce problem
  1. On a wiki with AbuseFilter installed, create two filters with Special:AbuseFilter/new
    1. One with Revoke the user's autoconfirmed status checked in the Actions to take when matched section
    2. The other with Block the user and/or IP address from editing checked instead
  2. Go to Special:AbuseFilter, find the two filters you just created and make a note of their Filter IDs
  3. Run the SearchFilters.php maintenance script with the --consequence="block" parameter
    1. Locally on bare metal, run php maintenance/run.php AbuseFilter:SearchFilters.php --consequence="block"
    2. On docker, run docker compose exec mediawiki php maintenance/run.php AbuseFilter:SearchFilters.php --consequence="block"
    3. On beta (if you have access), run mwscript extensions/AbuseFilter/maintenance/SearchFilters --wiki=enwiki --consequence="block"

Expected behaviour: Response lists the ID of the filter you created with Block the user and/or IP address from editing consequence, but not the other filter
Observed behaviour: Response lists the IDs of both filters you created

Environment

Wiki(s): https://en.wikipedia.beta.wmflabs.org Abuse Filter – (aee25cf) 10:19, 27 August 2024.

Event Timeline

It seems tricky, but it can be rewritten to something like this (maybe it can be generalized to a utility function?).

Change #1140780 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[mediawiki/extensions/AbuseFilter@master] Introduce findInSet() helper and fix SearchFilters.php

https://gerrit.wikimedia.org/r/1140780

Change #1140780 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Introduce findInSet() helper and fix SearchFilters.php

https://gerrit.wikimedia.org/r/1140780