Page MenuHomePhabricator

en.wikiversity JavaScript Failure: No edit tool bar etc. (due to mw.util.$content being null in MediaWiki:Common.js)
Closed, ResolvedPublic

Description

JavaScript appears to not be functioning on en.wikiversity for logged in users. It works anonymously (IP users), but isn't working logged in.

I noticed the problem earlier today. I didn't notice it previously. The last changes to JavaScript in our MediaWiki space was a week ago.

Please investigate.

Event Timeline

Aklapper changed the task status from Open to Stalled.Dec 1 2016, 12:53 PM

Hi @Dave_Braunschweig, thanks for taking the time to report this!
Please provide steps to reproduce, like how "not be functioning" can be seen. There are many many things using JavaScript and without some example URLs and steps which have recently created problems on Wikiversity, "investigating" could easily become a time sink.
For future reference, please see https://mediawiki.org/wiki/How_to_report_a_bug - thanks!

Aklapper changed the task status from Stalled to Open.Dec 1 2016, 1:02 PM

Ah, I missed "no toolbar when editing" on the wiki. It's extremely welcome if such info was included in Phabricator reports to save time, and linking to related info / discussion threads. :)

I opened the web browser's developer tools (for more info how to use web browser's developer tools, please see: Firefox ≥24 / Internet Explorer / Google Chrome / Apple Safari / Opera) and went to https://en.wikiversity.org/w/index.php?title=Wikiversity:Colloquium&action=edit&debug=true (note the &debug=true).

TypeError: mw.util.$content is null load.php:34:2
	<anonymous> https://en.wikiversity.org/w/load.php:34:2
	jQuery.Callbacks/fire https://en.wikiversity.org/w/load.php:3148:10
	jQuery.Callbacks/self.fireWith https://en.wikiversity.org/w/load.php:3260:7
	.ready https://en.wikiversity.org/w/load.php:3472:3
	completed https://en.wikiversity.org/w/load.php:3503:3

That line mw.util.$content.find('.editsection').each( function() { comes from https://en.wikiversity.org/wiki/MediaWiki:Common.js so the question is why mw.util.$content is empty.

Aklapper renamed this task from en.wikiversity JavaScript Failure to en.wikiversity JavaScript Failure: No edit tool bar etc. (due to mw.util.$content being null in MediaWiki:Common.js).Dec 1 2016, 1:05 PM

Demonstration page identifying multiple JavaScript-controlled user-interface elements:
https://en.wikiversity.org/wiki/Wikiversity:JavaScript

Thanks!

I commented out the offending code in https://en.wikiversity.org/wiki/MediaWiki:Common.js . That moves the JavaScript load error, but does not resolve it. I'm not an experienced JavaScript developer, and I'm having problems locating where it moved the problem to. Any additional hints would be greatly appreciated.

en.wikiversity JavaScript appears to be working correctly now. Please advise as to any changes made so I / we can understand where to look for these problems in the future, and perhaps avoid them.

Thanks!

You need to use mw.loader.using to make sure mediawiki.util has loaded before trying to access mw.util.$content. See https://www.mediawiki.org/wiki/ResourceLoader/Modules#mediawiki_2 for some documentation.

Thanks for your assistance on this. I've removed the problematic code from https://en.wikiversity.org/wiki/MediaWiki:Common.js . It did not appear to be necessary anymore.