Page MenuHomePhabricator

Abstract out parts of AbuseFilterViewEdit that deal with saving a filter
Closed, ResolvedPublic

Description

Right now, AbuseFilterViewEdit not only shows the interface for editing filters, but also handles the process of validating the input and saving a filter. As a result, it is impossible to use PHPUnit to create filters programmatically, to be used for unit testing later on.

Essentially, AbuseFilter is not using a MVC (or similar) model, and we should move towards it. As a first step, let's abstract out the parts of includes/Views/AbuseFilterViewEdit.php that deal with validating user input (on the edit filter form) and saving it to the database, into a separate method under includes/AbuseFilter.php perhaps a static method called AbuseFilter::saveFilter() (or even better, a public static method AbuseFilter::saveFilter() that validates input and a private static method AbuseFilter::doSaveFilter() that actually writes to the database).

Event Timeline

Huji triaged this task as High priority.May 2 2018, 2:52 AM
Huji created this task.
Restricted Application added subscribers: OldUser02, Aklapper. · View Herald TranscriptMay 2 2018, 2:52 AM

Agreed. My proposal is to have an AbuseFilter::validateFilter() method for validating input, returning errors etc. and an AbuseFilter::saveFilter() method to write to the DB.

Huji added a comment.May 2 2018, 4:10 PM

Equally good.

Change 430437 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] [WIP] Abstract methods in ViewEdit related to filter saving

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

Daimona claimed this task.May 2 2018, 7:26 PM
Vvjjkkii renamed this task from Abstract out parts of AbuseFilterViewEdit that deal with saving a filter to ntdaaaaaaa.Jul 1 2018, 1:12 AM
Vvjjkkii removed Daimona as the assignee of this task.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed the point value for this task.
Vvjjkkii removed subscribers: gerritbot, Aklapper, Huji.
Daimona renamed this task from ntdaaaaaaa to Abstract out parts of AbuseFilterViewEdit that deal with saving a filter.Jul 1 2018, 12:50 PM
Daimona claimed this task.
Daimona updated the task description. (Show Details)
Daimona added subscribers: gerritbot, Aklapper, Huji.

Change 430437 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Abstract methods in ViewEdit related to filter saving

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

Huji closed this task as Resolved.Jul 2 2018, 10:23 PM
Huji removed a project: Patch-For-Review.