Page MenuHomePhabricator

Sometimes portlet links are unstyled in Minerva (e.g. PageTriage tool)
Closed, ResolvedPublic

Description

To reproduce:

  1. Log in with an account that has the patrol user right.
  2. Go to a random page.
  3. Open the "More" menu.

Screenshot:

Screen Shot 2019-12-11 at 10.48.13 AM.png (428×361 px, 70 KB)

Here is the code that creates the link:

var sidebarLink = mw.util.addPortletLink(
	'p-tb',
	'#',
	mw.msg( 'pagetriage-enqueue-title' ),
	'p-pagetriage-enqueue',
	mw.msg( 'pagetriage-enqueue-tooltip' )
),

Event Timeline

ovasileva triaged this task as Medium priority.Jan 7 2020, 4:55 PM
ovasileva added a subscriber: alexhollender.

@Jdlrobson - Now that T231925 is fixed, what code should PageTriage be using to create the link? I was thinking that it would get fixed automatically by T231925, but it still looks broken as in the description screenshot.

@kaldari "who wrote that" is working for me and when I run the code in Pagetriage it also works.

I suspect there is a race condition here - either in the client side hook system or PageTriage not considering the loading of skins.minerva.scripts
mw.hook( 'util.addPortletLink' ).add( require( './addPortletLink.js' ) );

Screen Shot 2020-04-14 at 3.12.24 PM.png (682×1 px, 296 KB)

Screen Shot 2020-04-14 at 3.10.05 PM.png (914×2 px, 467 KB)

This extension is not maintained by reading web so moving to tracking.

kaldari added a subscriber: ovasileva.

I just ran into the same thing, also with a gadget/personal script of mine:

Screenshot 2020-05-29 at 19.03.42.png (1×2 px, 236 KB)

It doesn't happen consistently though. This is a race condition. Refreshing usually means a different one ends up unstyled. The PageTriage tool is unstyled most of the time, probably due to having less code behind it before calling (more prone to hit the race condition). Although every one in a while, it does get styled correctly.

This happens because we're using mw.hook() incorrectly. I should have realised this as part of T231925...

The mw.hook() interface is used for things like wikipage.content, wikipage.categories, and more. What they have in common is that they are considered better than a $() dom-ready callback because we can fire out hook a second time if they have been replaced. For example, during a live preview, or after publishing an edit with VisualEditor, after lazily loading a piece of content, or adding a gallery in VE.

This means the hook name is meant to refer to a single conceptual thing, not several of the same kind of thing.

In short: Only the last item added is seen by the Minera skin JS code when it registers its handler. This is required by the mw.hook contract and cannot be changed (doing so would break all its intended use cases, and also cause a memory leak).

Krinkle renamed this task from Link for PageTriage in tool menu looks broken in MinervaNeue to Sometimes portlet links are unstyled in Minerva (e.g. PageTriage tool).May 29 2020, 6:11 PM

Change 723299 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] Improve support in Minerva for addPortletLink

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

Change 723299 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Improve support in Minerva for addPortletLink

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

Change 723326 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] Enhance icons of previously added items

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

Change 723326 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Enhance icons of previously added items

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

Jdlrobson closed this task as Resolved.EditedSep 28 2021, 4:33 PM
Jdlrobson claimed this task.

This should be fixed on the beta cluster.
https://en.m.wikipedia.beta.wmflabs.org/wiki/Conflict-title-0.4285846299453995-I%C3%B1t%C3%ABrn%C3%A2ti%C3%B4n%C3%A0liz%C3%A6ti%C3%B8n

Please reopen this ticket if it doesn't seem to be working.