Page MenuHomePhabricator

Work with community to fix faulty gadgets triggering JS errors
Closed, ResolvedPublic

Description

The following gadgets appear to be causing JS error for users that load them. I don't have stack traces for them right now because of T259369 but have been able to manually replicate a few.

This task tracks identifying the source of the problem and helping get them fixed.
The offending scripts should be fixed or blanked

Fixed?ScriptTest urlJS errorPossible maintainer
https://he.wikipedia.org/w/index.php?title=%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9:Bharel/%D7%A1%D7%A7%D7%A8%D7%99%D7%A4%D7%98%D7%99%D7%9D/64-new-min.js&action=raw&ctype=text/javascript?Uncaught TypeError: Cannot set property 'onclick' of null ; uncaught exception: [object Object]?
https://ca.wikipedia.org/wiki/Usuari:Georg-hessen/monobook.js (entire script is broken)All pagesUncaught ReferenceError: addTab is not defined@Georg-hessen
https://he.wikipedia.org/w/index.php?title=MediaWiki:%D7%A1%D7%A7%D7%A8%D7%99%D7%A4%D7%98%D7%99%D7%9D/98.jshttps://he.wikipedia.org/wiki/%D7%A8%D7%9D_%D7%91%D7%9C%D7%99%D7%A0%D7%A7%D7%95%D7%91Uncaught TypeError: Cannot read property 'he' of undefined@חזרתי
https://he.wikipedia.org/wiki/%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:Gadget-CiteTooltip.jsHover over [5] on ירדן ירדן כ-2.7-2.1 מיליון[4][5] in https://he.wikipedia.org/w/index.php?title=%D7%A4%D7%9C%D7%A1%D7%98%D7%99%D7%A0%D7%99%D7%9D&oldid=29041005Uncaught Error: Syntax error, unrecognized expression: #cite_note*@קיפודנחש
YEShttps://he.wikipedia.org/w/index.php?title=User:Guycn2/Edittoolbar.jsAll pagesUncaught TypeError: $(...).wikiEditor is not a function@Guycn2
https://he.wikipedia.org/w/index.php?title=MediaWiki:%D7%A1%D7%A7%D7%A8%D7%99%D7%A4%D7%98%D7%99%D7%9D/1.jsAll pagesUncaught ReferenceError: dateblock is not defined@IKhitron
https://meta.wikimedia.org/wiki/User:Mike.lifeguard/blockOptions.jshttps://www.mediawiki.org/wiki/Topic:Vlxq3or3tf4p1ozvUncaught ReferenceError: wgCanonicalSpecialPageName is not definedretired but still used by people
https://meta.wikimedia.org/w/index.php?title=User%3AMike.lifeguard%2FaddTools.js&action=raw&ctype=text/javascripthttps://www.mediawiki.org/wiki/Topic:Vlxq3or3tf4p1ozvUncaught TypeError: document.getElementById(...) is nullretired but still used by people
https://commons.wikimedia.org/w/index.php?title=MediaWiki%3AGadget-Cat-a-lot.jshttps://ca.wikipedia.org/w/index.php?title=Diccionari_descriptiu_de_la_llengua_catalana&action=edit(Uncaught ReferenceError: catALot is not defined)?
xhttps://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.jshttps://ca.wikipedia.org/w/index.php?title=Plantilla:Infotaula_eleccions/proves&action=editUncaught TypeError: regExpMatch is undefined [1], Error: Another textSelection API was already registered@Cacycle
https://meta.wikimedia.org/w/index.php?title=User:Xiplus/TwinkleGlobal.jshttps://ca.wikipedia.org/wiki/Usu%C3%A0ria_Discussi%C3%B3:AranyaUnknown@Xiplus
https://www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.jshttps://ca.wikipedia.org/w/index.php?title=Usuari_Discussi%C3%B3:MarinaABC&action=submitUnknownUser:Remember the dot
https://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.jshttps://ca.wikipedia.org/wiki/Mass%C3%ADs_de_la_MaladetaUnknown@dschwen
https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.jshttps://ca.wikipedia.org/wiki/Viquiprojecte:Doblatge_en_valenci%C3%A0UnknownUnknown
https://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.jshttps://ca.wikipedia.org/wiki/Miriam_EscofetUnknown?

Replication steps

  1. Take the URL in column "script"
  2. Append &action=raw&ctype=text%2Fjavascript&maxage=2419200&smaxage=2419200 to the end of the URL and pass it to mw.loader.getScript eg.
mw.loader.getScript('https://commons.wikimedia.org/w/index.php?title=MediaWiki%3AGadget-Cat-a-lot.js%2Fca&action=raw&ctype=text%2Fjavascript&maxage=2419200&smaxage=2419200' );

[1] Stack trace

Uncaught TypeError: regExpMatch is undefined
    Find https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript:9982
    EditButton https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript:8163
    <anonymous> https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript line 4374 > eval:1
    EditButtonHandler https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript:4374
    TurnOn https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript:3699
    Setup https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript:2396
    Startup https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript:2080
    <anonymous> https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript:19206
index.php:9982:13

Event Timeline

Jdlrobson renamed this task from Fix faulty gadgets being loaded on Catalan Wikipedia to Fix faulty gadgets erroring with "ScriptError" being loaded on Catalan Wikipedia.Jul 31 2020, 7:39 PM
Jdlrobson created this task.
Jdlrobson updated the task description. (Show Details)Aug 1 2020, 5:50 AM
Jdlrobson added a subscriber: Cacycle.
Jony added a subscriber: Jony.Aug 1 2020, 8:56 AM
Jdlrobson updated the task description. (Show Details)Aug 1 2020, 8:47 PM
Krinkle renamed this task from Fix faulty gadgets erroring with "ScriptError" being loaded on Catalan Wikipedia to Fix faulty gadgets erroring with "Script error" on Catalan Wikipedia.Aug 1 2020, 9:20 PM
Nirmos added a subscriber: Nirmos.Aug 11 2020, 5:20 AM

After a quick investigation, none of the following seem to be used anywhere in the cawiki MediaWiki namespace:
blockOptions
addTools
TwinkleGlobal

Nirmos added a comment.EditedAug 11 2020, 6:56 AM

They aren't used anywhere in the cawiki User namespace either:
blockOptions
addTools
TwinkleGlobal

They are used on meta in users' global.js, though:
blockOptions
addTools
TwinkleGlobal

Why do some of the test urls go to mediawikiwiki if this task is about cawiki? For example the first one with blockOptions. If I enter

mw.loader.load( 'https://meta.wikimedia.org/w/index.php?title=User:Mike.lifeguard/blockOptions.js&action=raw&ctype=text/javascript' );

in the console on https://www.mediawiki.org/wiki/Topic:Vlxq3or3tf4p1ozv I get "Uncaught ReferenceError: wgCanonicalSpecialPageName is not defined", just as the task says, but that is because mediawikiwiki has turned off global JavaScript variables (T72470). That does not happen on cawiki.

Jdlrobson renamed this task from Fix faulty gadgets erroring with "Script error" on Catalan Wikipedia to Fix faulty gadgets erroring with "Script error" on our test wikis (Catalan Wikipedia and mediawiki.org).Aug 11 2020, 2:47 PM

It started of as cawiki but I expanded it to include mediawiki.org as I found them. I've updated the title to reflect the status quo.

Yep am aware of T72470 being the cause. The script should still be fixed as it's going to break in more places as T72470 rolls out further.

Jdlrobson updated the task description. (Show Details)Aug 12 2020, 6:59 PM

@Vriullop, are you interested in scripts, or can you tell me who at the Catalan Wikipedia might be interested in fixing some of these scripts?

TheDJ updated the task description. (Show Details)Aug 20 2020, 11:24 AM
TheDJ added a subscriber: dschwen.
TheDJ updated the task description. (Show Details)Aug 20 2020, 11:27 AM

@Vriullop, are you interested in scripts, or can you tell me who at the Catalan Wikipedia might be interested in fixing some of these scripts?

There are currently no script maintainers in ca.wiki. I will make a call in case any dormant user can help.

KRLS added a subscriber: KRLS.Aug 24 2020, 6:15 AM
Jdlrobson renamed this task from Fix faulty gadgets erroring with "Script error" on our test wikis (Catalan Wikipedia and mediawiki.org) to Work with community to fix faulty gadgets triggering JS errors.Aug 26 2020, 6:21 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson added subscribers: IKhitron, Guycn2.
Jdlrobson updated the task description. (Show Details)Aug 26 2020, 6:29 PM
Jdlrobson updated the task description. (Show Details)Aug 26 2020, 6:43 PM

@Vriullop I could do with your help letting user Georg-hessen know that their monobook script is broken : https://ca.wikipedia.org/wiki/Usuari:Georg-hessen/monobook.js Could you help with that?

@IKhitron The CiteTooltip gadget on Hebrew Wikipedia is one of the main sources of errors in our JavaScript - about 60% of the errors we are seeing in Hebrew Wikipedia since we enabled logging today. Would it be possible for you to ping the maintainer and request they look into the bug?

Jdlrobson updated the task description. (Show Details)Aug 26 2020, 10:14 PM
Jdlrobson updated the task description. (Show Details)Aug 26 2020, 10:17 PM

@Vriullop I could do with your help letting user Georg-hessen know that their monobook script is broken : https://ca.wikipedia.org/wiki/Usuari:Georg-hessen/monobook.js Could you help with that?

The tool called Viquiestris is known as deprecated with no maintenance for a long time. I have commented it out and explained the reason to the user.

I don't know why MediaWiki:Wikiminiatlas.js is on that list. The JS Error column shows "Unknown" and I cannot replicate any error on the linked page.

Krinkle removed a subscriber: Krinkle.Aug 27 2020, 5:27 PM

@dschwen unfortunately, since this script is on meta wikimedia and loaded by other wikis eg. Catalan, Hebrew, for security reasons the stack trace is hidden and it displays as "Script error".

Given the low volume (about 46 every hour) it's likely hidden somewhere in the interface.
I'm working hard to get the stack trace for that error. Any help trying to identify it from users of the script would be helpful.

Adding the following to user scripts would make a user visible alert to when the error occurs if anyone is interested playing detective:

 mw.trackSubscribe( 'resourceloader.exception', function ( topic, data ) {
alert(topic + JSON.stringify(data)); 
                } );
                // setup the global error handler
                mw.trackSubscribe( 'global.error', function ( topic, error ) {
alert(error);
                } );

@IKhitron I've fixed the citetooltip issue, but I've found another issue with a user script - this one with https://he.wikipedia.org/wiki/%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9:Ori/monobook.js which throws Uncaught ReferenceError: AddTemplateToList is not defined. Would it be possible for you to reach out to User:Ori to get that fixed?

IKhitron added a subscriber: eranroz.EditedAug 29 2020, 11:42 PM

@IKhitron I've fixed the citetooltip issue, but I've found another issue with a user script - this one with https://he.wikipedia.org/wiki/%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9:Ori/monobook.js which throws Uncaught ReferenceError: AddTemplateToList is not defined. Would it be possible for you to reach out to User:Ori to get that fixed?

Your try can be good as mine. He's not so available as years ago, so User talk page is the best option. And also, do you know how to fix it? If you don't, maybe a better way for you is pinging here 'eranroz'.

IKhitron removed a subscriber: eranroz.Aug 30 2020, 12:07 AM

@IKhitron thanks for getting back to me on Ori's code. I've gone ahead and patched it myself given his unavailability.

However, I found a new error today in https://he.wikipedia.org/w/index.php?title=%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9:Bharel/%D7%A1%D7%A7%D7%A8%D7%99%D7%A4%D7%98%D7%99%D7%9D/64-new-min.js&action=raw&ctype=text/javascript

The error is Uncaught TypeError: Cannot set property 'onclick' of null.
It also threw an error uncaught exception: [object Object] on https://he.wikipedia.org/w/index.php?title=%D7%9E%D7%A9%D7%A7%D7%A4%D7%99%D7%99%D7%9D&curid=30970&diff=29090426&oldid=29089910

Unfortunately, the code seems to be minified, so I can't see what's wrong here. I'd appreciate if you reached out to its maintainer to get these issues looked into.

Jdlrobson updated the task description. (Show Details)Sep 2 2020, 5:30 PM

I'm also seeing (and fixing) a large amount of problematic scripts on Hebrew Wikipedia which use mw.util.addPortletLink must neglect to deal with the case where the link is not added and returning null. https://he.wikipedia.org/w/index.php?title=%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99%3A%D7%A1%D7%A7%D7%A8%D7%99%D7%A4%D7%98%D7%99%D7%9D%2F41.js&type=revision&diff=29165290&oldid=17655871

Me fixing these might not scale so I wonder if we can identify such scripts (via an appropriate search query) and run a user notice/send talk page messages for those. Does anyone have any experience with doing such things?

Well, I think you can find them using regular wikisearch. And yes, I did fix it once on MediaWiki-extensions-GlobalWatchlist.

The non minified version can be accessed by removing the "min" at the end. I'll take a look at it when I have the chance.

@Bharel you'll need to replace

mw.util.addPortletLink('p-tb', '#', 'הגדרות סקריפט 64').onclick =
       this.SettingsDialog.openDialog.bind(this.SettingsDialog);

with
var link = mw.util.addPortletLink('p-tb', '#', 'הגדרות סקריפט 64');
if ( link ) {

link.onclick =
      this.SettingsDialog.openDialog.bind(this.SettingsDialog);

}

as sometimes addPortletLink returns null.
Guycn2 removed a subscriber: Guycn2.Sep 14 2020, 9:54 PM
Jdlrobson closed this task as Resolved.Oct 16 2020, 11:11 PM
Jdlrobson claimed this task.

I am now using https://meta.wikimedia.org/wiki/User:Jdlrobson/User_scripts_with_client_errors to communicate these errors. Please watch that page for new errors to fix :). Thanks in advance!