Page MenuHomePhabricator

Introduce an account_type variable
Closed, ResolvedPublic

Description

The discussion in T405440 highlights the need for a reliable way to determine the type of account being created during autocreateaccount. At present, this often requires using a brittle condition like accountname regex '^~2'.

This approach has several drawbacks:

  • It breaks global filters in wiki-farm environments where some projects have Temporary Accounts enabled and others don't.
  • Although the condition may look simple enough, why it works may not be obvious to users who are unfamiliar with matchPattern in the $wgAutoCreateTempUser configuration.
  • The pattern '^~2' will break in the future, though not imminently.

Acceptance criteria

  • Introduce an account_type variable
  • Rename accountname to account_name, deprecating the former

Event Timeline

Change #1224692 had a related patch set uploaded (by Dragoniez; author: Dragoniez):

[mediawiki/extensions/AbuseFilter@master] Introduce account_type and rename accountname to account_name

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

Change #1224695 had a related patch set uploaded (by Dragoniez; author: Dragoniez):

[mediawiki/extensions/CentralAuth@master] Replace accountname with account_name following upstream change

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

Change #1225077 had a related patch set uploaded (by Dragoniez; author: Dragoniez):

[mediawiki/extensions/AbuseFilter@master] Add account_type variable

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

Change #1225080 had a related patch set uploaded (by Dragoniez; author: Dragoniez):

[mediawiki/extensions/AbuseFilter@master] Complete renaming from accountname to account_name

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

Change #1225077 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Add account_type variable

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

Dreamy_Jazz updated the task description. (Show Details)

All patches have a +2, just waiting for them to be merged by CI

Change #1224692 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Rename accountname to account_name

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

Change #1224695 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Replace accountname with account_name following upstream change

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

Change #1225080 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Complete renaming from accountname to account_name

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

@Dreamy_Jazz Thank you so much for the multiple reviews.

This change should probably be announced to the community. Here's my suggestion:

* <translate>A new AbuseFilter variable, <tvar name="1"><code>account_type</code></tvar>, has been added to provide a reliable way to determine the account type being created in the <tvar name="2"><code>createaccount</code></tvar> and <tvar name="3"><code>autocreateaccount</code></tvar> actions. As part of this change, the variable <tvar name="4"><code>accountname</code></tvar> has been renamed to <tvar name="5"><code>account_name</code></tvar>, and the former is now deprecated. Please update any filters that use hardcoded account type checks or the deprecated variable.</translate> [https://phabricator.wikimedia.org/T414049]

I have announced this at the English Wikipedia, see this discussion I started.

I have announced this at the English Wikipedia, see this discussion I started.

Thanks for your help!

Difference between user_type should be explained.

Difference between user_type should be explained.

"user_type" is the type of user who did the edit or the operation. "account_type" is the type of the account which is being created in the "createaccount" or "autocreateaccount" operation. During the "autocreateaccount" operation, the users from other wikis are identified to be unregistered users by the abusefilter, but the "account_type" parameter of the operation is "named" for the abusefilter.

From https://www.mediawiki.org/wiki/Extension:AbuseFilter/Rules_format#Variables_always_available:

Type of the account being created, which will be one of the following: named, temp, unknown. The only difference from user_type (aside from the available values being a subset) is that this does not return ip for temporary users. Available only in the createaccount and autocreateaccount actions.

I went ahead and changed from accountname to account_name as the former was deprecated as of today (in my time zone) to some abuse filters at English Wikibooks, English Wikiquote, and Meta-Wiki. Anyone with global abuse filter helper rights (at the minimum) can see the changes I've made recently.