Page MenuHomePhabricator

Remove legacy scripts/non-RL mode from Gadgets extension
Closed, ResolvedPublicBUG REPORT

Description

I think it is time we remove the non-RL mode from Gadgets.

  1. Turn makeLegacyWarning into a log deprecate.
  2. Track on the deprecation dashboard.
  3. Inform wikis of their old/broken gadgets
  4. When satisfactory, remove code of the old legacy gadgets from the extension.

Background

  • Disabling "legacy" gadgets

See also:

Warning on Special:Gadgets:

Gadget is not loaded. Please migrate to ResourceLoader. (Learn more)
{F62358421 height=100}

Warning in the browser console:

Gadget "RegeMenuFramework" was not loaded. Please migrate it to use ResourceLoader. See https://beta.wikiversity.org/wiki/Special:Gadgets.
{F62358424 height=100}

Event Timeline

hhmm. this legacy warning is injected before we have full mw.log it seems. that makes tracing them a bit hard. I guess we can scan each page and see if there is still a wiki out there with that flag..

pattern: /^\*.*\[((?!ResourceLoader).)*\].*\.js.*$/gm

Change #1155179 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/extensions/Gadgets@master] Remove legacy mode and treat all gadgets as being in RL mode

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

It seems Elastic doesn't support the (?!word) negative lookahead syntax (i.e. Perl-like), so the above example doesn't work correctly, when run on the Global Search tool, or via mwgrep.

But, it does support a "complement" operator (docs) which does something similar:

mwgrep --title Gadgets-definition '\*~(.*(ResourceLoader).*)\.js'
## Public wiki results
arwikiquote         MediaWiki:Gadgets-definition
betawikiversity     MediaWiki:Gadgets-definition
enwikinews          MediaWiki:Gadgets-definition
eswiki              MediaWiki:Gadgets-definition
fawikisource        MediaWiki:Gadgets-definition
fawikivoyage        MediaWiki:Gadgets-definition
gewikimedia         MediaWiki:Gadgets-definition
huwikinews          MediaWiki:Gadgets-definition
itwikisource        MediaWiki:Gadgets-definition
kawiki              MediaWiki:Gadgets-definition
ladwiki             MediaWiki:Gadgets-definition
ltwiki              MediaWiki:Gadgets-definition
mkwiki              MediaWiki:Gadgets-definition
mkwikisource        MediaWiki:Gadgets-definition
mlwikibooks         MediaWiki:Gadgets-definition
mlwikisource        MediaWiki:Gadgets-definition
nlwikibooks         MediaWiki:Gadgets-definition
pawikisource        MediaWiki:Gadgets-definition
pswikivoyage        MediaWiki:Gadgets-definition
ptwikiquote         MediaWiki:Gadgets-definition
ptwikiversity       MediaWiki:Gadgets-definition
sawikisource        MediaWiki:Gadgets-definition
simplewiki          MediaWiki:Gadgets-definition
simplewikibooks     MediaWiki:Gadgets-definition
simplewikiquote     MediaWiki:Gadgets-definition
slwiki              MediaWiki:Gadgets-definition
slwikiquote         MediaWiki:Gadgets-definition
slwikisource        MediaWiki:Gadgets-definition
slwikiversity       MediaWiki:Gadgets-definition
strategywiki        MediaWiki:Gadgets-definition
tenwiki             MediaWiki:Gadgets-definition
wikimania2014wiki   MediaWiki:Gadgets-definition
zhwiki              MediaWiki:Gadgets-definition

Global Search for the above query.

The list is short enough to be a plausible list of lefovers. Spot-checking this indeed seems correct:

  • arwikiquote contains * ShortLink|ShortLink.js and various others like it.
  • zhwiki contains * mainpage-customization|mainpage-customization.js although it is commented out, it is a genuine match.

I've added the following context to the task description:

See also:

Warning on Special:Gadgets:

Gadget is not loaded. Please migrate to ResourceLoader. (Learn more)
{F62358421 height=100}

Warning in the browser console:

Gadget "RegeMenuFramework" was not loaded. Please migrate it to use ResourceLoader. See https://beta.wikiversity.org/wiki/Special:Gadgets.
{F62358424 height=100}

Hi! I just re-run the global code search and it seems like several wikis already removed their legacy gadgets.

So as a global interface editor, I commented-out the remaining ones. I think commenting-out is better than removing because:

  • Removing makes us "lose track" of the associated JS and CSS files
  • If the [ResourceLoader] flag is removed from all wikis programmatically (not sure if this was ever the intention) the legacy gadgets will remain commented-out
  • If someone wants to re-enable a legacy gadget after so many years, we can expect they'll do some basic testing and fixes, and not just assume it will work

Hopefully this will unblock this task, but if any more changes are needed, let me know and I'll be happy to help.

Change #1155179 merged by jenkins-bot:

[mediawiki/extensions/Gadgets@master] Remove legacy mode and treat all gadgets as being in RL mode

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

Izno subscribed.

Probably good to put in tech news, I'm just not sure of good wording. Probably just

Interface administrators can remove the ResourceLoader invocation in [[MediaWiki:Gadgets-definition]].

But probably there should be some dedicated documentation in a paste or task or on MW wiki that describes the changes that can be made and any caveats or gotchas (including the earlier comments out). Possibly in the context of the general migration guide, possibly in the context of Ext:Gadgets.

@Izno @TheDJ

Please check the accuracy:

Wikis with older gadgets that do not use ResourceLoader will be affected as support for this legacy loading method is removed from the Gadgets extension. The change will deprecate and eventually remove the old code, with affected wikis notified about gadgets that need to be migrated. ResourceLoader is MediaWiki’s system for efficiently loading JavaScript and CSS. Interface administrators may need to update older gadgets to use ResourceLoader to ensure they continue working. They can remove the ResourceLoader invocation in [[MediaWiki:Gadgets-definition]]. [https://phabricator.wikimedia.org/T298199]

I'm afraid I don't understand "They can remove the ResourceLoader invocation"; also how/where will affected wikis get notified about gadgets that need to be migrated?

@STei-WMF This change doesn't affect any wikis. Non-RL gadgets were disabled a loong time back (c. 2014 I think). Any non-RL gadgets don't load as of today and emit a warning on Special:Gadgets. We just removed this warning and other remnants of historical non-RL support. All non-RL gadget definitions were already cleaned up.

It does have a user-facing change though: wikis no longer need to set the ResourceLoader option in gadget definitions, because it is now implied.

@SD0001, if you do not mind, please go ahead and edit the text to make it accurate.

The only thing is that one line entries like: "Interface administrators can remove the ResourceLoader invocation in [[MediaWiki:Gadgets-definition]]." will need to be expanded to give some of these details:

Who (exactly) is the target audience? (E.g. admins? Wikipedia-only editors? all users in some specific languages?)? - in this case Interface administrators
What (exactly) is happening? - this isn't clear in the entry, I have tried to deduce that from the ticket
Why is it changing, or how is it an improvement? - this isn't clear in the entry
How should editors react? What action they should take (e.g. Make edits, share feedback, etc) - seems like "remove the ResourceLoader invocation in [[MediaWiki:Gadgets-definition]]"
Where can they learn more? - I will link to this ticket
When is the change happening? (If it's a deployment-train feature, use "later this week". Keep in mind the newsletter is delivered on Mondays.) - not clear

per these guidelines: https://meta.wikimedia.org/wiki/Tech/News/Manual#Writing_guidelines.

Hi. Am I correct to assume that this would be the valid change after above is deployed?

obraz.png (916×378 px, 36 KB)

So int admins can just replace (\[ResourceLoader\]|ResourceLoader\|) with an empty string, right?

Yes

@STei-WMF I would put it as:

Interface administrators can configure gadgets from [[MediaWiki:Gadgets-definition]]. The definition format has been updated to no longer require the "ResourceLoader" option, as gadgets are always loaded through ResourceLoader.

Can we get https://www.mediawiki.org/wiki/Extension:Gadgets#Usage fixed (or added to, to be clear for older versions) for the new format?

Why do I get this error when trying to remove all ResourceLoader mentions in https://fr.wikipedia.org/wiki/MediaWiki:Gadgets-definition ?

Screenshot_20260904_065231_Opera.jpg (1,080×2,104 px, 485 KB)

edit: I nulledited a js page to be asked to reauthed and I was able to edit Gadgets-definition

It looks like you did the JS edit on the desktop site, not the mobile site, is that right? If so, that may have masked the underlying issue. I expect that once that re-auth times out and resets, you'll have the same issue again, including when making any other edits to MediaWiki:Gadgets-definition, as well as any edit on MediaWiki:Common.js or MediaWiki:Gadget-refErrors.js.

This is not specific to gadgets, or ResourceLoader, or this task. I think what's going on is that there's an issue in the MobileFrontend editor with pages that require re-auth. Based on the screenshot it looks like you opened the editor without a reload (i.e. not action=edit but rather a JS-based overlay). I can't seem to reproduce that on my account, but I'm guessing some combination of user preference and edit button context triggers the modal editor instead of full-page editor, and that's possibly where the issue is.

Can you file a separate task about that?

It looks like you did the JS edit on the desktop site, not the mobile site, is that right? If so, that may have masked the underlying issue. I expect that once that re-auth times out and resets, you'll have the same issue again, including when making any other edits to MediaWiki:Gadgets-definition, as well as any edit on MediaWiki:Common.js or MediaWiki:Gadget-refErrors.js.

This is not specific to gadgets, or ResourceLoader, or this task. I think what's going on is that there's an issue in the MobileFrontend editor with pages that require re-auth. Based on the screenshot it looks like you opened the editor without a reload (i.e. not action=edit but rather a JS-based overlay). I can't seem to reproduce that on my account, but I'm guessing some combination of user preference and edit button context triggers the modal editor instead of full-page editor, and that's possibly where the issue is.

Can you file a separate task about that?

I filed T437019: Mobile editor does not provide a reauth flow. This issue is only with RawHTML pages. When I edit a JS or CSS page, the 2010 editor is used automatically so I did not need to use a desktop to trigger reauth flow.

SD0001 claimed this task.

I ripped this out on testwiki - please provide any feedback if fallout

$( '#wpTextbox1' ).text( function( i, v ) {
	return v
		.replace( /\[ResourceLoader\]/g, '' )
		.replace( /\|ResourceLoader\|/g, '|' )
		.replace( /\|ResourceLoader\]/g, ']' )
		.replace( /\[ResourceLoader\|/g, '[' );
} );