Page MenuHomePhabricator

Refactor edit constraint classes to be stateless
Open, Needs TriagePublic

Description

In order to be able to inject dependencies into edit constraint classes, they should ideally be stateless so we don't have to create new instances every time we want to check constraints.

To pass data from a failed constraint to EditPage, we could use subclasses of EditPageStatus.

Details

Event Timeline

Along with this, I'll also look into whether it would make sense to implement some sort of interface that allows storing data after a save attempt and reusing it in the next one, e.g. to allow bypassing warnings by saving twice. This is currently done through properties in EditPage, but right now it would be hard to implement something similar in an extension if the edit constraint system was stable.

Change #1277278 had a related patch set uploaded (by SomeRandomDeveloper; author: SomeRandomDeveloper):

[mediawiki/core@master] [POC] Remove state from RedirectConstraint

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