Page MenuHomePhabricator

Action should functionally determine the set of available variables
Open, Needs TriagePublic

Description

(Per conversation at https://th.wikipedia.org/wiki/User:Daimona_Eaytoy)

The convention in the filter language is that the variable action should tell what built-in variables are available, but this is actually not the case for some actions. E.g., the action createaccount might or might not make the user_name variable available.

This is not desirable for two reasons:

1.) We currently caution filter writers that they should check the action variable first to see what variables are available:

Caution: Always check that the variables you want to use are available for the current action being filtered, e.g. by using the action variable. Failing to do so (for instance using accountname for an edit, or edit_delta for a deletion) will make any code using the variable in question return false.

But the caution won't give the desired result in all cases as long as action doesn't functionally determine the set of available variables.

2.) The DUNDEFINED value is a source of various problems. The value could arise in two situations:

  • The use of a user-defined variable that was set in a non-taken branch.
  • The use of an unavailable built-in variable.

If it is possible to prevent both situations statically, then there will be no need for this value anymore.

The infrastructure for detecting the first case is implemented in https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/AbuseFilter/+/551966/. However, the second case is currently not possible to implement, being blocked by this issue.

Event Timeline

For built-in variables, this could be doable. At the moment, the only inconsistency is the one you mentioned about user_ vars not being available in *createaccount actions when the creator is not logged in. However, it will be harder for other extensions' variables.