Page MenuHomePhabricator

Uncaught TypeError: mw.centralNotice.isBannerShown is not a function
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

throw new Error();

What happens?:

Uncaught TypeError: mw.centralNotice.isBannerShown is not a function
    at log (https://meta.wikimedia.org/w/load.php?debug=2&modules=ext.wikimediaEvents&version=ztntf:514:62)
    at Object.<anonymous> (https://meta.wikimedia.org/w/load.php?debug=2&modules=ext.wikimediaEvents&version=ztntf:593:4)
    at Object.handler (https://meta.wikimedia.org/w/load.php?debug=2&modules=mediawiki.base&version=ztntf:400:14)
    at fire (https://meta.wikimedia.org/w/load.php?debug=2&modules=jquery&version=ztntf:3501:31)
    at Object.fireWith (https://meta.wikimedia.org/w/load.php?debug=2&modules=jquery&version=ztntf:3631:7)
    at Object.fire (https://meta.wikimedia.org/w/load.php?debug=2&modules=jquery&version=ztntf:3639:10)
    at mw.track (https://meta.wikimedia.org/w/load.php?debug=2&modules=mediawiki.base&version=ztntf:370:17)
    at window.onerror (https://meta.wikimedia.org/w/load.php?debug=2&modules=mediawiki.base&version=ztntf:1067:6)

What should have happened instead?:

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

This looks more like an error in the WikimediaEvents extension. That extension appears to assume that the CentralNotice function isBannerShown() is available, however, it's only there in some circumstances, depending on which CentralNotice campaigns, if any, are currently targeting the wiki on which the pageview occurred.

@AndyRussG: Please add project tags in that case, so tasks could be found or seen. Thanks.

Change 884522 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/extensions/WikimediaEvents@master] Fix error in client error logging banner check

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

Change 884522 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] clientError: Fix error in mw.centralNotice.isBannerShown check

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

Thanks @Jdlrobson! I'll make a CN patch just to always expose a mw.centralNotice.isBannerShown() function no matter what, since that seems like the most logical way for the CN JS API to work, and would prevent errors like the one mentioned in the task description.

(Not sure I follow what the error you linked in Logstash is, though. No one should be visiting Special:BannerLoader directly--it's just for background calls to load the banner to be injected. I see https://en.wikipedia.org/wiki/Data_aggregation in the url field on that link, though.)

@AndyRussG I think the issue here is inside the banner itself.

According to the error report it occurs on the file URL:
https://meta.wikimedia.org/w/index.php?title=Special:BannerLoader&campaign=Wiki+Loves+Folklore+2023+International&banner=wikilovesfolklore2023&uselang=en&debug=false

So something is loading that code and executing it and it's throwing an error. I'm assuming this code should only be executed if a banner is shown? e.g. if the code is being loaded mw.centralNotice.isBannerShown() should be true, but it seems like it's not? is something else happening? Perhaps this is being hit during preview? if so perhaps the URL could be updated to include a query string to allow filtering e.g. https://meta.wikimedia.org/w/index.php?title=Special:BannerLoader&campaign=Wiki+Loves+Folklore+2023+International&banner=wikilovesfolklore2023&uselang=en&debug=false&mode=preview