Page MenuHomePhabricator

Allow plain-numeric serial mapping to avoid conflicts when generating temp user names
Closed, ResolvedPublic

Description

Background

When generating temporary user names, the $wgAutoCreateTempUser['serialMapping']['type'] config determines how the unique, numerical part of the name is generated.

The simplest of these is plain-numeric, handled by the PlainNumericSerialMapping class, which returns an index stored in the database.

Problem

When changing modes, as required in the parent task, this can cause naming conflicts.

Solution

We can avoid this by defining a $wgAutoCreateTempUser['serialMapping']['offset'] config, which defines an integer added to the stored index by PlainNumericSerialMapping, and setting it to something above the maximum generated number for an existing temporary user name.

Event Timeline

Change 983471 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/core@master] Temp users: Add 'offset' option for PlainNumericSerialMapping

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

Change 983471 merged by jenkins-bot:

[mediawiki/core@master] Temp users: Add 'offset' option for PlainNumericSerialMapping

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

Testing steps

Test locally, with temp accounts enabled.

  1. Add the following config:

$wgAutoCreateTempUser['serialMapping']['type'] = 'plain-numeric';

  1. Log out and create a temporary user by making an edit. Note the user name.
  2. Add the following config:

$wgAutoCreateTempUser['serialMapping']['offset'] = 1000;

  1. Log out and create a temporary user by making an edit.

The name generated for the second user should be c.1000 higher than for the first user. (Exactly 1001 higher if $wgAutoCreateTempUser['serialProvider']['numShards'] is set to the default of 1.)

@Tchanders Testing locally with $wgAutoCreateTempUser['serialMapping']['offset'] = 1000;. My last temp user was "*Unregistered 1370".

  • After making an edit, the new temp username is "*Unregistered 2371".
  • I exit the session and make another edit. The next temp username is "*Unregistered 2372".

I notice that the table user_autocreate_serial is only incremented by 1.

If all subsequent temp usernames are only incremented by 1, do we not still risk naming conflicts?

Perhaps I have not understood the problem this is supposed to fix.

@Tchanders Testing locally with $wgAutoCreateTempUser['serialMapping']['offset'] = 1000;. My last temp user was "*Unregistered 1370".

  • After making an edit, the new temp username is "*Unregistered 2371".
  • I exit the session and make another edit. The next temp username is "*Unregistered 2372".

I notice that the table user_autocreate_serial is only incremented by 1.

If all subsequent temp usernames are only incremented by 1, do we not still risk naming conflicts?

Perhaps I have not understood the problem this is supposed to fix.

The offset is applied so that you have your temporary account usernames starting with their IDs above the current maximum ID used by a temporary account.

For example, lets say that Special:ListUsers shows the following temporary accounts in order and the uas_value is 3:

  1. *Unregistered 2
  2. ...
  3. *Unregistered 234
  4. ...
  5. *Unregistered 2234

You would then add an offset of 2231 so that new temporary accounts would start at *Unregistered 2235 as no temporary account has an ID of 2235 or greater on the wiki.

The offset is applied so that you have your temporary account usernames starting with their IDs above the current maximum ID used by a temporary account.

OK, thanks for the clarification. In that case, it appears to be behaving as desired.