Page MenuHomePhabricator

Enable showing UserInfoCard in content areas
Closed, ResolvedPublic

Description

Summary

The UserInfoCard doesn't currently render for usernames rendered in content areas. T392775 describes some of the mechanics needed to support this.

Note that this task does *not* cover DiscussionTools (T423949, T396709).
This task is to cover the UIC card in the content pages that are used for the AIV and SPI pages, for the top 5 wikis in annual plan (en, de, ja, es and fr)

Acceptance criteria

  • The UIC button displays for user links in content areas
  • The UIC button displays for external user links in content areas (e.g. for the noping template)

Reflecting the user's blocked status is not part of this task, it'll be implemented in T433958: Display blocked user icon for UIC buttons in content. For this task, it's sufficient to have either normal or temporary account icon in the UIC button.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
mszwarc subscribed.

Implementation plan

There are two main options to go with this:

  • Display the UIC button next to every user link, which is present in the content area.
  • Add a mechanism to explicitly specify "render UIC button here" in the wikitext.

Given that we would prefer to do a slower and targeted rollout of UIC in the page content, instead of rendering it basically everywhere, we'd like to choose the second option. Additional factor that supports it, is the fact that user links can be in different forms (userpage, contribs, external link etc.), which makes it quite hard to match and interpret all reasonable forms of "user link". We don't want to add increased complexity here, like it was the case with gray backgrounds for temporary account links.

We're thinking that the UIC will be added onto a page using a new parser function, {{#uic:...}}, accepting the target user name as its first parameter (for example, {{#uic:Msz2001}}). This design will help in to ways: first, it's going to make the UIC invocation abstract from the actual strcture of the HTML to be placed there (no mw-ui-button type of legacy wikitext), and second, we'll be able to tweak the amount of HTML emitted to balance between UIC being opt-in and no significant FOUC. In future, we might want to allow for additional arguments to this function.

Minimally, the output of the {{#uic:...}} function will be just an empty HTML placeholder, such as , to be inflated by a JS code, loaded only for users who enabled UIC in their preferences. However, given that it can lead to FOUC, we'd like to make the function emit an HTML

Change #1320679 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/CheckUser@master] Extract UIC button renderer from hook handler

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

Change #1320680 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/CheckUser@master] UIC: Add support for content pages

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

Change #1321514 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/core@master] Make Parser implement MessageLocalizer

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

Change #1320679 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] Extract UIC button renderer from hook handler

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

Change #1321514 merged by jenkins-bot:

[mediawiki/core@master] Make Parser implement MessageLocalizer

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

Change #1320680 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] UIC: Add support for content pages

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

Thank you to everyone who made this happen!!

Would someone smarter than me be able to add #uic to https://www.mediawiki.org/wiki/Help:Magic_words? (I don't know which section it belongs in, nor do I know the technical details to add an appropriate blurb.) Thanks in advance :)

Would someone smarter than me be able to add #uic to https://www.mediawiki.org/wiki/Help:Magic_words?

Documented it on https://www.mediawiki.org/wiki/Help:Extension:CheckUser#User_Info_card_in_page_content

The Help:Magic_words page seemed to me like it's primarily about the core's magic words and I couldn't find a good place on that page to include the UIC function.

I've added a notice about this task to the next Tech News issue:

User Info card is a feature that helps patrollers see information about user accounts. So far, it has been available only in places such as page history, logs and recent changes. Now, it's possible to place it in the page content as well, using the {{#uic:}} parser function. It can be particularly useful in templates like {{Userlinks}} (or their speciaized variants), as it will make it easier to see the context about a user on various noticeboard pages. The card will be displayed only to users who have it enabled in their preferences.

IKhitron subscribed.

Thanks a lot, it's great! Is there a way to add something like {{#uic:|enwikisource}}, to show the data from different wiki site?

Thanks a lot, it's great! Is there a way to add something like {{#uic:|enwikisource}}, to show the data from different wiki site?

UserInfoCard doesn't support querying remote wikis and we don't have it in our current plans to add such a functionality.

Thanks a lot, it's great! Is there a way to add something like {{#uic:|enwikisource}}, to show the data from different wiki site?

UserInfoCard doesn't support querying remote wikis and we don't have it in our current plans to add such a functionality.

A pity. Thank you for your answer.

There is a tracking category there. Please consider excluding the old IP addresses from it, as missing the target of its creation.

There is a tracking category there. Please consider excluding the old IP addresses from it, as missing the target of its creation.

Yes, it's tracked in T435169: {{#uic}} parser function should allow to skip tracking category when invoked with IP address. We'll split the tracking category into two (one for IP targets, and other for everything else). Then, the wiki will be able to disable the former if they want (using Special:TrackingCategories, by changing the relevant message to -).

There is a notable delay and movement from having these elements on a page like https://ru.wikipedia.org/wiki/Википедия:Запросы_к_администраторам/Быстрые
Can some mitigation for that be added so that, if a user has these cards enabled, they don’t get a visible change to layout after the button gets rendered? For instance, by always reserving some space for it when .client-js class is present? I’ll note that it’s not a problem with watchlist etc., so there’s something specific to this implementation that gets delayed rendering.

There is a notable delay and movement from having these elements on a page like https://ru.wikipedia.org/wiki/Википедия:Запросы_к_администраторам/Быстрые
Can some mitigation for that be added so that, if a user has these cards enabled, they don’t get a visible change to layout after the button gets rendered? For instance, by always reserving some space for it when .client-js class is present? I’ll note that it’s not a problem with watchlist etc., so there’s something specific to this implementation that gets delayed rendering.

Hi! When I open the page, I see that the user icons are added immediately to the page content, and the only thing that causes a reflow is the "Show IP" button. Is it the same to what you see?

I think there’s some sort of discrepancy between the skins: in Vector 2022 I do see it added immediately, but in old Vector I see it added a few seconds after the page has loaded.

Change #1331507 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/CheckUser@master] UIC: Fix in-interface invocations of {{#uic:}} (client-side)

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

I think there’s some sort of discrepancy between the skins: in Vector 2022 I do see it added immediately, but in old Vector I see it added a few seconds after the page has loaded.

You're right. It seemed that presence of Codex Button styles (which are, at least partially, loaded by Vector 2022) helped to display the UIC button immediately after page load. I have included the relevant part of button's styles in the UIC module, which should help. Full button Codex Button definition (CSS+JS) arrives together with JS module for UserInfoCard, so I didn't want to fully duplicate all the styles in the style-only module.

I think something is broken. When I try non-existing user, there is no tracking category as before, and the icon does not disappear as before. Instead, I get a wrong ID error.

image.png (712×545 px, 26 KB)

Looks like it shows the old tracking category for all IPv6, I'm not sure.

When I try non-existing user, there is no tracking category.

That was the desired behavior, actually. The tracking categories are added to page when the wikitext is parsed. The result of a parse is then cached and reused for subsequent page views. I means that if the account gets created shortly after such a page is parsed, the category wouldn't disappear at the same time (and UIC couldn't reappear, if it was skipped the same way as it's now for invalid targets).

Maybe the error message should be better, but I propose to track it as a separate task, so as that it'll be clear what the status is etc.

Looks like it shows the old tracking category for all IPv6, I'm not sure.

I did a quick round of tests and wasn't able to reproduce. Can you point me to an example?

When I try non-existing user, there is no tracking category.

That was the desired behavior, actually. The tracking categories are added to page when the wikitext is parsed. The result of a parse is then cached and reused for subsequent page views. I means that if the account gets created shortly after such a page is parsed, the category wouldn't disappear at the same time (and UIC couldn't reappear, if it was skipped the same way as it's now for invalid targets).

Maybe the error message should be better, but I propose to track it as a separate task, so as that it'll be clear what the status is etc.

I do not speak about the preview, it's just for visualization. The tracking category for wrong user names of registered users does not work any more.

Looks like it shows the old tracking category for all IPv6, I'm not sure.

I did a quick round of tests and wasn't able to reproduce. Can you point me to an example?

My bad, it was because of another problem. Let me rephrase: any usage of #uic with any type of IP and bullets breaks the parser.

image.png (382×272 px, 9 KB)

The tracking category for wrong user names of registered users does not work any more.

I can still observe the tracking category being added for e.g., {{#uic:inv#lid name}}. It's meant for invalid names as opposed to non-existing users, and has been working in such a way from the very beginning.

Looks like it shows the old tracking category for all IPv6, I'm not sure.

I did a quick round of tests and wasn't able to reproduce. Can you point me to an example?

My bad, it was because of another problem. Let me rephrase: any usage of #uic with any type of IP and bullets breaks the parser.

image.png (382×272 px, 9 KB)

It's interesting, for me such wikitext renders correctly: https://test.wikipedia.org/wiki/User:MSzwarc-WMF/UIC

image.png (536×327 px, 21 KB)

The tracking category for wrong user names of registered users does not work any more.

I can still observe the tracking category being added for e.g., {{#uic:inv#lid name}}. It's meant for invalid names as opposed to non-existing users, and has been working in such a way from the very beginning.

I'm in shock. Thank you for the explanation.

Looks like it shows the old tracking category for all IPv6, I'm not sure.

I did a quick round of tests and wasn't able to reproduce. Can you point me to an example?

My bad, it was because of another problem. Let me rephrase: any usage of #uic with any type of IP and bullets breaks the parser.

image.png (382×272 px, 9 KB)

It's interesting, for me such wikitext renders correctly: https://test.wikipedia.org/wiki/User:MSzwarc-WMF/UIC

image.png (536×327 px, 21 KB)

Weird.

Change #1331507 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] UIC: Fix in-interface invocations of {{#uic:}} (client-side)

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