Page MenuHomePhabricator

The mw.user object needs to be rewritten
Closed, DeclinedPublic

Description

What the title says. It's a pretty terrible interface, and needs to be redesigned. Here are some of the issues with it:

  • Is just an object, so there's no way for other code to make user objects for other users,
  • Has a bunch of functions (see user.bucket(), user.sessionId()) that don't belong there,
  • Doesn't give you an IP address for anonymous users when calling getName(), making it tough to get an identifier for that user (E:Annotator just ran into this problem),
  • Doesn't have username validation functions, which would be useful for client-side validation.

In the end, it's only useful purpose is the ability to retrieve the current user's name and ID, and even then the getId and getName functions are just wrappers for mw.config, so it's pretty trivial to get the info manually.


Version: 1.22.0
Severity: normal

Details

Reference
bz52894

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:48 AM
bzimport set Reference to bz52894.
bzimport added a subscriber: Unknown Object (MLST).
Krinkle closed this task as Declined.Apr 12 2020, 10:12 PM

The things from mw.user that can reasonably be performed on other users has since been made available via mediawiki.api, e.g. mw.Api#getUserInfo provides user rights and user groups.

All the other functions in mw.user, which are described in the task description as "don't belong there", are in fact what mw.user is for. Having the getRights() and getGroups() functions there as convenience seems useful, but that is not its main purpose.