From the parent task:
- The prefix for temporary usernames will be ~YYYY-n where YYYY indicates the year when the temporary username is created
- The identifying temp user # n is broken into groups of 5 separated by hyphens. If the numbers don't neatly divide into groups of 5 then the very last group on the right can have fewer numbers.
- At the end of every year n is reset and the counting starts all over.
Handled elsewhere: changing the prefix, resetting the counter each year.
Temporary user names are generated by TempUserCreator::acquireName:
private function acquireName(): string { $index = $this->getSerialProvider()->acquireIndex(); $serialId = $this->getSerialMapping()->getSerialIdForIndex( $index ); return $this->config->getGeneratorPattern()->generate( $serialId ); }
This combines the genPattern and the string generated from serialMapping, defined on the AutoCreateTempUser config.
The serialMapping option determines how to map a unique integer to a unique string for the user name.
There are a few approaches we could use here:
- Add a hook to acquireName that can be handled by WikimediaMessages can use to add a year and the hyphens
- Add another serialMapping type that adds the year and hyphens
- Add another config option addYear that can be used with any serialMapping
, and also addhyphens for specifying whether numbers will be broken up by hyphens, and how many numbers should be in each group
(1) is my preference, since it keeps the code base clean, and allows for any more tweaks. However, it feels a little dangerous to rely on WikimediaMessages for usernames everywhere, but I'm not quite sure why...
(2) and (3) seem brittle and as though we're adding unnecessary WMF-specific complexity to core
Chosen approach: (3), as discussed in the comments.