Page MenuHomePhabricator

Remove message boxes with IDs in core
Closed, ResolvedPublic

Description

Editors: Please review these uses, and remove or replace the CSS IDs, as needed:

  • #mw-anon-edit-warning shown on the editor for anonymous users and used in McrUndoAction.php. Not used in JavaScript, 42 23 usages across gadgets/user scripts
  • #mw-anon-preview-warning shown when anonymous user previewing their changes in McrUndoAction.php and EditPage.php. Unused in code, 5 3 global search results.
  • #mw-undelete-revision shown on Special:Undelete. Unused in code, 13 12 global search results
  • #mw-preferences-success used on Special:Preferences and SpecialLUserrights and Extension:CentralAuth. Unused in code. 0 results in global search.
  • #mw-userinvalidconfigtitle and #mw-previewconflict in EditPage.php. Both has no usage in code an globally (1, 2).

Original task:
The Html class has methods messageBox, warningBox and errorBox. Currently these support the creation of message boxes in a standardized way.

There are several instances where we create message boxes with ID attributes in our code.
[See list above]

The question is what should we do about these?

Options

  1. Allow message boxes to define an ID.

This would complicate the Html function API and also encourage bad behaviours such as shipping styles that are usually unused for most page views, changing the default styles for certain message boxes and using the warning to check state e.g. consider this code:

var isAnon = !!document.getElementById( 'mw-anon-edit-warning' );
  1. Retain the IDs but move them to container elements

e.g.

$out->addHTML(
			Html::rawElement(
				'div',
				[ 'id' => 'mw-anon-edit-warning' ],
				Html::warningBox( $html )
			)
		);
  1. Drop the IDs.

Decision

Let’s go with 3), dropping the IDs.

Acceptance criteria

For the following drop the use of the ID attribute and use the HTML methods.

  • Use HTML::warningBox inside includes/actions/McrUndoAction.php
  • Use HTML::warningBox and HTML::errorBox inside EditPage.php
  • Use HTML::warningBox includes/specials/SpecialUndelete.php
  • Use HTML::successBox inside includes/specials/SpecialUserrights.php
  • Use HTML::successBox inside includes/specials/SpecialPreferences.php
  • When the code is merged, we should add the User-notice tag to make clear these IDs have been removed.

Sign off

Event Timeline

Jdlrobson renamed this task from Should we allow message boxes with IDs>? to Should we allow message boxes with IDs?.Mar 21 2022, 8:17 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson updated the task description. (Show Details)
Jdlrobson added a subscriber: Volker_E.

@Volker_E I'm leaning towards option 3 since usage is so low. Thoughts?

I also think option 3 is the right direction. Option 2 is likely to cause more issues than what it resolves, as on-wiki styles (but maybe sometimes scripts as well) expect that the element with the ID is the same as the warning box—for example, wikt:de:MediaWiki:Common.css sets a background color, which makes no sense if the message box is within the styled box and thus overrides the background color. Such issues mean that on-wiki code needs to be cleaned up by someone anyway, but then we could just migrate to a specific class instead of a specific ID.

Tacsipacsi changed the subtype of this task from "Bug Report" to "Task".Mar 22 2022, 1:53 AM

By the way, I don’t think this task is about any bug—not providing a way to specify an ID is a lack of feature, not a bug.

Last call for input here, otherwise I will push ahead with a recommendation to remove the IDs.

Jdlrobson renamed this task from Should we allow message boxes with IDs? to Remove message boxes with IDs in core.Apr 20 2022, 6:06 PM
Jdlrobson triaged this task as Medium priority.
Jdlrobson updated the task description. (Show Details)
  • When the code is merged, we should add the User-notice tag to make clear these IDs have been removed.

I think it should be in Tech News before getting merged. #mw-anon-edit-warning has been around for almost 1.5 decades (since 7af20970abc), let’s give people a chance to fix usages before they break.

That's fine, when there's a patch submitted we can start the process, but there's no point running a User-notice until someone submits a patch or expresses an intent to work on this one.

I think most of the work here is replacing on-wiki usage, the changes in code seem to be pretty straightforward, I’m sure there will be someone to do it. (Maybe me.) It’s not without precedent that changes are announced in Tech News months in advance, without an exact timeline yet, and then announced again right before the change as a heads-up. (If it has been announced before, it’s fine if the heads-up announcement appears in Tech News on Monday of the week it rides the train.)

Change 786436 had a related patch set uploaded (by Stang; author: Stang):

[mediawiki/core@master] Remove message boxes with IDs in core

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

Suggested text: Several IDs related to mediawiki interface messages will be removed from MediaWiki software. Script developers should please review impacted scripts in this ticket.
(I'll target merging the above patch April 27th so that it goes out on the train of 9th May)

A little bit quick...? I would prefer a more comprehensive review as some replacement I am not pretty sure.

Why should it be merged today to get on the train departing in 12 days? If it’s merged by May 10, 01:00 UTC, it still catches the same train. However, the Tech News note should be released ASAP (i.e. in the May 2 issue) to give communities as much time to prepare as possible.

By the way, what’s up with next week’s train (May 3–5)? I don’t see any note about it not happening in the roadmap.

Usually, 2 weeks is more than enough time, especially for something that impacts less than 100 scripts (usually we run user notices for thousands of impacted scripts). This is not urgent from my perspective so I am happy to delay code review as long as you need, please let me know via a ping here or on Gerrit (make sure you give me "attention" when you are ready for me to review and merge.

Hi. For Tech News purposes, I'm uncertain about how to clarify the draft provided above, and I think someone needs to improve the "action items" for editors who turn up here.

  1. For the basic information in Tech News (I.e. readers thinking "do I need to look any further?") I imagine something like this is accurate and clear, but I need a confirmation or improvements, before I'll add it to the draft:

Several CSS IDs related to MediaWiki interface messages will be removed. Script developers should please review the list of IDs and links to their existing uses. These include #mw-anon-edit-warning, #mw-undelete-revision and 3 others.

  1. For the Task Description at top, I believe it is currently unclear what exactly editors are supposed to do, if they check the global-search links and find that they are using one of these IDs in their [script/gadget/user-CSS].
    • I.e. Are there simple-replacements? Is it contextually different for each use-case? --
    • I'd suggest clarifying the Description to make it more 'actionable', by adding a new section at the top that is aimed at those readers.
  1. re: Deployment Train - I believe Tacsipacsi is correct, and there are normal Trains running until August, per https://wikitech.wikimedia.org/wiki/Deployments/Yearly_calendar
  1. For the basic information in Tech News (I.e. readers thinking "do I need to look any further?") I imagine something like this is accurate and clear, but I need a confirmation or improvements, before I'll add it to the draft:

Several CSS IDs related to MediaWiki interface messages will be removed. Script developers should please review the list of IDs and links to their existing uses. These include #mw-anon-edit-warning, #mw-undelete-revision and 3 others.

Not only JavaScript (“script authors”) is affected, but also CSS—actually, as far as I remember (global search seems to be down right now), the majority of affected pages is CSS. I don’t have an idea how to communicate this briefly but precisely, though.

  1. For the Task Description at top, I believe it is currently unclear what exactly editors are supposed to do, if they check the global-search links and find that they are using one of these IDs in their [script/gadget/user-CSS].
    • I.e. Are there simple-replacements? Is it contextually different for each use-case? --
    • I'd suggest clarifying the Description to make it more 'actionable', by adding a new section at the top that is aimed at those readers.

Unfortunately this turned out to be less straightforward as it seemed at first. Currently there’s no replacement that will definitely work. Maybe it’s indeed too early to be in Tech News… Or you can add it now, as the entry seems to be clear, and if the task description doesn’t become actionable by Monday, it’s still not too late to be postponed.

To be clear, the amount of scripts impacted here is tiny on the grand scale of things - 60 scripts (42 + 5 + 13) and to be honest most of these overrides are bad - as they break consistency across projects. The fix here is likely removing these selectors (to using a different selector if needed), but given the low impact I am not sure it makes sense to work out what those selectors are until somebody tells us they are important.

For instance on https://frr.wikipedia.org/wiki/Augusto_Palacios?action=edit&veswitched=1

Before change:

Screen Shot 2022-04-28 at 2.10.41 PM.png (816×2 px, 334 KB)

After change:

Screen Shot 2022-04-28 at 2.11.05 PM.png (998×2 px, 358 KB)

@Tacsipacsi suggested in corresponding patch to replace those id with class to kind of reduce the impact of such removal, and I thought it should be discussed at here.

  1. Tech News: I've added it (https://meta.wikimedia.org/wiki/Tech/News/2022/18) as:

Several CSS IDs related to MediaWiki interface messages will be removed. Technical editors should please review the list of IDs and links to their existing uses. These include #mw-anon-edit-warning, #mw-undelete-revision and 3 others.

I will freeze it for translations in ~2 hours (edits welcome before then).

  1. I've updated the Description to hopefully make it a bit clearer, especially for ESL folks. Please check for accuracy. Thanks!

Change 786436 merged by jenkins-bot:

[mediawiki/core@master] Remove message boxes with IDs in core

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

Hi @Quiddity could we run another announcement that this change will be going out this week? Thanks in advance!

@Jdlrobson Hiyo! I've updated the Global Searches in the task description to be namespace-specific. (because (a) Tech News mentioned two examples, so there were hundreds of new entries in the search results! (b) hopefully a few have been fixed since the last announcement!)

  • Question: Please confirm that we only need to check these 3 namespaces: Template/User/MediaWiki ?

Re: a new announcement

  • We could announce a change next week, but not this week. (Tech News is frozen for translations on Friday and delivered on Monday)
  • If we do announce it again, it would be good to highlight where the problems are in some way, in order to save time for folks who don't need to be distracted.
    • I.e. Tech News goes to 1,000+ pages and gets translated into 20+ languages.
    • I wonder if someone watching this task (with InterfaceAdmin rights) could fix most of those remaining problems, in less time than it would take us to collectively [write/translate/read/click to here/click to global search/check if 'my' wiki is in the list]...?
    • If not, and we really do need more people to help, then perhaps could we do something at a smaller level to get the correct people's attention? E.g. A massmessage to the talkpages of the affected pages? E.g. a single message to the Global Interface Admins?
  • Question: Your thoughts?
Question: Please confirm that we only need to check these 3 namespaces: Template/User/MediaWiki ?

Correct.

I wonder if someone watching this task (with InterfaceAdmin rights) could fix most of those remaining problems, in less time than it would take us to collectively [write/translate/read/click to here/click to global search/check if 'my' wiki is in the list]...?

You are probably right. We can skip tech news. It's not worth the effort given the low impact.

The challenge here is I believe most of these can be safely removed. #mw-anon-edit-warning and #mw-undelete-revision previously did not use message box styles so the value of overriding them is pretty low at this point and I would advocate removing all the rules. For example, on Hebrew, there is CSS in Common.css which changes the icon opacity, which I'm not sure it a good idea. So there is an element of judgement to be had here. Would it be controversial to remove them and then if there's any controversy, point them to this ticket in the edit summary? Do we know anyone who has a script that could automate fixing these?

The possible solutions that could be scripted are:

  • Replace #mw-anon-edit-warning with`.action-edit #mw-content-text > .mw-message-box-warning`
  • Remove #mw-anon-edit-warning CSS selector
  • Remove #mw-undelete-revision CSS selector
  • Replace #mw-undelete-revision with .mw-special-Undelete .mw-message-box-warning (untested)
Jdlrobson claimed this task.