Bug 458903 - "wgPageName not defined" JavaScript error from site JavaScript on techbase and userbase wikis
Summary: "wgPageName not defined" JavaScript error from site JavaScript on techbase an...
Status: REPORTED
Alias: None
Product: KDE MediaWiki
Classification: Websites
Component: general (other bugs)
Version First Reported In: unspecified
Platform: unspecified All
: NOR normal
Target Milestone: ---
Assignee: carl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-09 01:20 UTC by skierpage
Modified: 2022-09-09 01:20 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description skierpage 2022-09-09 01:20:19 UTC
STEPS TO REPRODUCE
1. Open browser's developer console
2. Visit any page on those web sites, e.g. https://userbase.kde.org/Welcome_to_KDE_UserBase
3. Append ?debug=true and reload

OBSERVED RESULT
The Firefox browser console shows
Uncaught ReferenceError: wgPageName is not defined

If you append ?debug=true (see https://www.mediawiki.org/wiki/ResourceLoader/Architecture#Debug_mode ), the concatenated but uncompressed JavaScript reveals the broken code is from https://techbase.kde.org/MediaWiki:Common.js where you can have wiki-specific code, and indeed this has
   if (wgPageName == "Special:Search") //scripts specific to Special:Search
  {
      importScript("MediaWiki:Common.js/search.js")         |      importScript("MediaWiki:Common.js/search.js")
  }

EXPECTED RESULT
No error. MediaWiki has deprecated global wg variables for a decade, see https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#Global_wg_variables.

SOFTWARE/OS VERSIONS
N/A

ADDITIONAL INFORMATION
I can't fix this because editing https://techbase.kde.org/MediaWiki:Common.js (wisely!) restricted to users in some special group.

https://community.kde.org/MediaWiki:Common.js doesn't have this code, or seemingly any site JavaScript.

I think the rest of the JavaScript in common.js isn't loaded, so probably the search script https://userbase.kde.org/MediaWiki:Common.js/search.js isn't loaded; I think it wants to add searches of the kde wiki using "Windows Live" and other search engines. Fixing this bug is trivial, probably just replace with `mw.config.get('wgPageName') ` instead, but I think that will just lead to more JavaScript errors (e.g. wgUserGroups on userbase will also fail). Since search is working fine it's probably safest to remove all the JavaScript. The JavaScript was added to techbase and userbase by user Danimo back in 2009, and then user Nikerabbit tweaked it on userbase in 2011.