Page MenuHomePhabricator

Expand the SearchFilters.php maintenance script to search for filters with a given consequence
Closed, ResolvedPublic1 Estimated Story PointsFeature

Description

The SearchFilters.php maintenance script can be used to search for filters with given conditions. It should also be possible to search for filters with a given consequence. An example of this is to find filters which have enabled the showcaptcha consequence on WMF wikis

Acceptance criteria
  • Expand the SearchFilters.php maintenance script to be able to search by consequence

Event Timeline

Dreamy_Jazz changed the subtype of this task from "Task" to "Feature Request".Aug 22 2024, 8:42 PM

Change #1064898 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/AbuseFilter@master] Expand SearchFilters.php to search by consequence

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

Change #1064898 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Expand SearchFilters.php to search by consequence

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

Change #1067310 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/AbuseFilter@master] Allow consequence to be used without pattern in SearchFilters.php

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

Suggested QA steps which can be performed on a local wiki:

  1. Install AbuseFilter extension
  2. Load Special:AbuseFilter and create a few testing filters using the Create new filter button
    1. Each filter has to have a description and conditions. You can use page_id = 123456 as the conditions
    2. For some of these filters, check the Prevent the user from performing the action in question box in the Actions to take when matched section
  3. Go back to Special:AbuseFilter and note down the IDs of the filters where Disallow is listed in the consequences column
  4. Run SearchFilters.php --consequence="disallow"
  5. Verify that the output of the maintenance script contains just the IDs you noted down in step 3

Performing these steps on beta wikis or patch demo is not possible, because it requires running a maintenance script. You may also wish to repeat the above steps for different consequences, and also when using the --pattern option to filter for specific conditions.

Change #1067310 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Allow consequence to be used without pattern in SearchFilters.php

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

@Dreamy_Jazz Is it possible to search for --consequence="block" without also getting filters which have the blockautopromote consequence?

Is it possible to search for filters which have no consequences (and is this something admins would want?)

@Dreamy_Jazz Is it possible to search for --consequence="block" without also getting filters which have the blockautopromote consequence?

I had not considered this and it doesn't seem that it is currently possible. The script was modified to allow searching for the showcaptcha consequence (which does not collide in this way). I think that we can ignore this problem for the purposes of this ticket, as the scope was for allowing searching for showcaptcha filters.

We could probably file a new task to make the consequence option use regex (like the pattern option) so that it would be possible to exclude.

If you disagree, I can work on updating the script to make the option use regex.

Is it possible to search for filters which have no consequences (and is this something admins would want?)

The use case for adding the --pattern option was not to search for filters without any consequences, so it's not possible to do this at the moment. I think we can either file a new task or ignore this for the purposes of QA, for the reasons mentioned above.

@Dreamy_Jazz OK, if the current script fulfills the use case, I am fine with that. I will raise bugs for the follow-up tasks (for when/if we decide to do them).

@Dreamy_Jazz OK, if the current script fulfills the use case, I am fine with that. I will raise bugs for the follow-up tasks (for when/if we decide to do them).

I raised T373497 and T373498. I briefly considered raising a feature request to allow searching for filters with multiple consequences, but decided against it as I don't know if there is a use case for that.

I ran the maintenance script on beta for a few different consequences and checked it was returning the correct number of filters for a few different beta wikis. I did not systematically check that the specific filter IDs were correct.

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

Thanks for filing the tasks.