Jump to content

Topic on User talk:Roan Kattouw (WMF)/Flow

Nirmos (talkcontribs)

I just have to ask, is there a reason we aren't able to get the user name of IPs? mw.user.getName() returns null for IPs. At first, I thought maybe this is because of some security or privacy concern, but I'm not sure that makes any sense. Does it have to do with caching?

Ideally, mw.user.getName() should return the IP for IPs, and if you want to differentiate between IPs and logged-in users you would use mw.user.isAnon(), and mw.user.isAnon() would have to be reworked to no longer rely on mw.user.getName(). Unfortunately, that would be a breaking change for code that relies on comparing mw.user.getName() with null to tell IPs and logged-in users apart, but maybe that would be acceptable with enough communication (tech news, mailing lists, console.log)?

Roan Kattouw (WMF) (talkcontribs)

The reason is because the mw.config values are in a JSON blob that's embedded in the page, and page views for anons are cached (and therefore are reused between different IPs). This is also why the bar at the top right where your user name appears shows "Not logged in" instead of the IP.

MediaWiki can be configured to show the IP there, but that setting is incompatible with the Varnish cache that WMF uses, so it's only there for 3rd-party wikis.

Nirmos (talkcontribs)

Ahh, so it is because of cache. Okay, thanks for answering.

Nirmos (talkcontribs)

Ok, but what about making a new method called mw.user.getIP and make it async like mw.user.getGroups? Would that be acceptable?

Roan Kattouw (WMF) (talkcontribs)

I believe it would be. Like getGroups all it would need to do is send an API request for meta=userinfo

Nirmos (talkcontribs)