Page MenuHomePhabricator

When a page has multiple issue boxes but doesn't use multiple issues template, the icon is shared across all issues boxes.
Closed, ResolvedPublic

Description

When "Template:Multiple issues" is not used, results can be confusing:
The current implementation assigns the highest priority icon to all the issues in the ambox like so:

multiple-uncontained.png (1×750 px, 162 KB)

The expected behavior is that each issue would retain its original icon like so:

Screen Shot 2018-11-12 at 1.00.39 PM.png (390×655 px, 54 KB)

Precursor

  • T206177 talks about a more sustainable approach to handle severity and icons. It would be wise to talk/implement that first.
  • T211257 has split the code into sensible units with different responsibilities.

Replication steps

Production:
https://en.wikipedia.org/w/index.php?title=File_viewer&oldid=855442461&useskin=minerva&minerva-issues=b

Locally:

Developer notes

Right now our code assumes that there can be only one section per page issue and that an icon is decided by the maximum severity of issues in that section.

This happens in this code block:

if ( issues.length && $metadata.length && inline ) {
			issues[0].issue.icon.$el.prependTo( $metadata.eq( 0 ).find( '.mbox-text' ) );
			$learnMore = $( '<span>' )
				.addClass( 'ambox-learn-more' )
				.text( mw.msg( 'skin-minerva-issue-learn-more' ) );
			if ( $( '.mw-collapsible-content' ).length ) {
				// e.g. Template:Multiple issues
				$learnMore.insertAfter( $metadata.find( '.mbox-text-span' ) );
			} else {
				// e.g. Template:merge from
				$learnMore.appendTo( $metadata.find( '.mbox-text' ) );
			}
			$metadata.click( function () {
				overlayManager.router.navigate( issueUrl );
				return false;
			} );

Something like this is more desirable (looping through all the elements in $metadata):

		if ( issues.length && $metadata.length && inline ) {
			$metadata.each( function ( i, issueEl ) {
				var $learnMore, $issue = $( issueEl );
				issues[i].issue.icon.$el.prependTo( $issue.eq( 0 ).find( '.mbox-text' ) );

A sample and flawed patch exists: https://gerrit.wikimedia.org/r/#/c/mediawiki/skins/MinervaNeue/+/475030/
When fixing this be careful of how multiple issues works (see T202349#4782266 and T202349#4801892)

QA steps

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Jdlrobson renamed this task from What to do with multiple issues that have not been combined? to What to do with multiple issues that have not been combined (currently merging icons)?.Sep 4 2018, 3:05 PM
Jdlrobson updated the task description. (Show Details)

Removing word confusion from description to avoid confusion.

Change 457928 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[mediawiki/skins/MinervaNeue@master] Fix page-issue icons for multiple issues in a single section

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

ovasileva raised the priority of this task from Low to Medium.Sep 4 2018, 4:29 PM
ovasileva set the point value for this task to 5.

Decided to estimate this at a 5 and check back in on Thursday, Sept 6 to see if we've uncovered more complexity.

To clarify: This affects the severity levels logged in the PageIssues schema in the same way, correct?

@Tbayer fortunately, the event-logging actually registers the severity correctly, phew!

Screen Shot 2018-09-05 at 19.34.03.png (668×3 px, 363 KB)

Change 458557 had a related patch set uploaded (by Niedzielski; owner: Stephen Niedzielski):
[mediawiki/skins/MinervaNeue@master] Hygiene: move page issue group parsing to parser

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

Change 464564 had a related patch set uploaded (by Niedzielski; owner: Stephen Niedzielski):
[mediawiki/skins/MinervaNeue@master] Hygiene: move page issue group parsing to parser

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

Change 458557 abandoned by Niedzielski:
Hygiene: move page issue group parsing to parser

Reason:
Moved to master branch since we don't seem to be using the page-issue-fixes branch. Unfortunately, using the same change ID and pushing for master created a second patch instead of updating this one: https://gerrit.wikimedia.org/r/#/c/mediawiki/skins/MinervaNeue/ /464564/.

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

Moving to upcoming so that we can discuss further during next grooming

I don't think this one's ready. We don't have any good solutions here. By all means chat about it, if the goal is to improve understanding, but I'm not confident we can estimate this in the time allotted.

I'd recommend talking about T206177 first as that change should help simplify this code considerably and provide us with a better route for making this problem go away.

Jdlrobson removed the point value for this task.Oct 8 2018, 9:12 PM

resetting estimate as I don't think we should rely on that one month old estimation.

Jdlrobson renamed this task from What to do with multiple issues that have not been combined (currently merging icons)? to When a page has multiple issue boxes but doesn't use multiple issues template, the icon is shared across all issues boxes..Oct 8 2018, 9:23 PM
Jdlrobson updated the task description. (Show Details)

Change 464564 merged by jenkins-bot:
[mediawiki/skins/MinervaNeue@page-issues-cleanup] Hygiene: move page issue group parsing to parser

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

Change 457928 abandoned by Jdlrobson:
Fix page-issue icons for multiple issues in a single section

Reason:
If still needed please post to master now :)

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

Jdlrobson renamed this task from When a page has multiple issue boxes but doesn't use multiple issues template, the icon is shared across all issues boxes. to Page issues: When a page has multiple issue boxes but doesn't use multiple issues template, the icon is shared across all issues boxes..Nov 15 2018, 6:51 PM
Jdlrobson moved this task from Triaged but Future to Upcoming on the Web-Team-Backlog board.
ovasileva renamed this task from Page issues: When a page has multiple issue boxes but doesn't use multiple issues template, the icon is shared across all issues boxes. to [Spike 8hrs] Page issues: When a page has multiple issue boxes but doesn't use multiple issues template, the icon is shared across all issues boxes..Nov 20 2018, 5:44 PM

Change 475030 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/skins/MinervaNeue@master] Every ambox has its own issue and icon

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

Following on from our conversation I took a stab at fixing this. The patch attached resolves the issue. Maybe we could all take some time to look through the patch and have a think about the risk involved.

phuedx set the point value for this task to 0.Nov 22 2018, 3:03 PM

@Jdrewniak pointed out my proposal patch breaks multiple issues. It looks like our multiple issues code also makes assumptions! Guess what.. we assume that in multiple issues the first issue is the highest priority!
See https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=Multiple_issue_fail&venotify=created&mobileaction=toggle_view_mobile for example!

While true, this seems like a big oversight on our part.
We can continue to support this hack (And document it with the following change to my patch)

diff --git a/resources/skins.minerva.scripts/pageIssues.js b/resources/skins.minerva.scripts/pageIssues.js
index 376890b5fb..c0f08b3fae 100644
--- a/resources/skins.minerva.scripts/pageIssues.js
+++ b/resources/skins.minerva.scripts/pageIssues.js
@@ -94,9 +94,22 @@
 		if ( issues.length && inline ) {
 			// amboxes and issues are guaranteed to have the same length because of the way
 			// they are constructed above.
-			issues.forEach( function ( issue ) {
-				var $learnMore, $box = issue.$source;
-				issue.issue.icon.$el.prependTo( $box.find( '.mbox-text' ) );
+			issues.forEach( function ( issue, i ) {
+				var $prependTo,
+					$learnMore, $box = issue.$source,
+					grouped = issue.issue.grouped;
+
+				if ( !grouped ) {
+					$prependTo = $box.find( '.mbox-text' );
+				} else if ( i === 0 ) {
+					// Multiple issues case!
+					// Assumes only one grouping and its the first item in the page
+					// assumes the highest issue is the first element..
+					$prependTo = $metadata.find( '.mbox-text' );
+				} else {
+					return;
+				}
+				issue.issue.icon.$el.prependTo( $prependTo );
 				$learnMore = $( '<span>' )
 					.addClass( 'ambox-learn-more' )
 					.text( mw.msg( 'skin-minerva-issue-learn-more' ) );

I've folded this into https://gerrit.wikimedia.org/r/#/c/mediawiki/skins/MinervaNeue/+/475030

ovasileva raised the priority of this task from Medium to High.Nov 29 2018, 4:41 PM

I’ve finally gotten around to looking over @Jdlrobson’s updated patch, but alas, I’ve found another bug, it breaks the overlay for multiple-issues templates. :(

Personally though, I feel uneasy about iterating on this patch because the code in the file is hard enough to reason about as it is, and I think adding more conditionals and code-paths into the existing structure will make it harder to maintain in the future.

I’ve taken a birds-eye view of the file in question, and I’ve assembled some of my notes on wiki:
https://www.mediawiki.org/wiki/User:JDrewniak_(WMF)/notes/The_issues_with_PageIssues_js

I basically just stepped through each line to try and make sense of what the functions are doing. This in itself was challenging.

Therefore, I think that in order to address this issue while maintaining confidence that we're not causing regressions, we should first split out the createBanner function into smaller functions.

Hopefully, that will allow us to work on a fix for this problem in isolation, and maybe write some more specific tests for it too.

Change 477993 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[mediawiki/skins/MinervaNeue@master] Refactor pageIssues.js into smaller functions

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

Change 475030 abandoned by Jdlrobson:
Every ambox has its own issue and icon

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

Jdlrobson renamed this task from [Spike 8hrs] Page issues: When a page has multiple issue boxes but doesn't use multiple issues template, the icon is shared across all issues boxes. to When a page has multiple issue boxes but doesn't use multiple issues template, the icon is shared across all issues boxes..Dec 11 2018, 8:11 PM
Jdlrobson changed the task status from Open to Stalled.
Jdlrobson removed Jdlrobson as the assignee of this task.
Jdlrobson updated the task description. (Show Details)
Jdlrobson removed the point value for this task.

I’ve finally gotten around to looking over @Jdlrobson’s updated patch, but alas, I’ve found another bug, it breaks the overlay for multiple-issues templates. :(

Yup. The hacky solution in T202349#4782266 is not great. I like your proposal so I've repurposed this spike as a task, put it back in the backlog and have stalled it on the new task.

Change 477993 merged by jenkins-bot:
[mediawiki/skins/MinervaNeue@master] Refactor pageIssues.js into smaller functions

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

Jdlrobson changed the task status from Stalled to Open.Dec 14 2018, 1:27 AM
Jdlrobson updated the task description. (Show Details)

It looks like T211257 may have fixed this. Let's QA!

☝️ From at the current AC for T210553: Deploy page issues to all wikipedias (except enwiki):

Ensure all subtasks are resolved (except T202349 and T204143)

i.e. this work doesn't formally block the deployment of the new page issues treatment. T202349#4827432 formalises this relationship.

Hey Olga since you are QAing page issues anyway could you QA and sign this off as well?