Page MenuHomePhabricator

Exception thrown by ext.math.editbutton.enabler - TypeError: mw.toolbar is undefined
Closed, ResolvedPublic


At I'm getting this error message in webconsole:

"Exception thrown by ext.math.editbutton.enabler" load.php:150
"TypeError: mw.toolbar is undefined" TypeError: mw.toolbar is undefined
Stack trace:
@ line 4 > eval:2:2316
@ line 4 > eval:2:2235
@ line 4 > eval:38:951

It doesn't seem to be a problem on any other pages that I can find.

Event Timeline

Quiddity raised the priority of this task from to Needs Triage.
Quiddity updated the task description. (Show Details)
Quiddity added a subscriber: Quiddity.
Ciencia_Al_Poder added a subscriber: Ciencia_Al_Poder.

Adding the JavaScript keyword.

This happens on every page that uses LiquidThreads.

The CharInsert buttons don't work on LiquidThreads messages now: they appear, but clicking on them does nothing

Apparently, ext.math.editbutton.enabler should require "mediawiki.toolbar" instead of assuming it has been loaded already:

This should be good first task to fix

Change 184127 had a related patch set uploaded (by Physikerwelt):
Add dependency to mediawiki.toolbar


@Aklapper, what's the intended effect by raising the priority of the issue. I have created a patch that needs to be reviewed and tested. So someone needs to assign himself to do that at some point in time in the future.

@Aklapper, what's the intended effect by raising the priority of the issue.

To keep track of things that should happen rather sooner than later. Feel free to revert/correct if you disagree with the set priority.

@Aklapper, no it's fine. But it might take month until it gets reviewed. So if it would be a really serious problem, I would have to contact someone, who takes care of the code review.

Aklapper lowered the priority of this task from High to Medium.Jan 12 2015, 8:58 PM

The underlying problem is that Math is doing something weird with the edit toolbar.

By design, no module should manually load the "mediawiki.toolbar" module. The toolbar module is loaded by core on the EditPage and then used to construct the classic toolbar. If you're not on an edit page, the code calling mw.toolbar.addButton must not run. If you run it anyway and then avoid the inevitable crash by adding a dependency on mw.toolbar you'd be loading a module that does nothing only to call a function that then also does nothing.

Instead, per

Load the addButton-code, and guard it with if ( mw.toolbar ). MediaWiki core will load the toolbar module as necessary based on the page, action and user preferences. And it loads it from the top queue so it may be depended on implicitly throughout the page run time.

It previously didn't throw on LiquidThreads, but it wasn't working either. So remove the dependency and add the if block to resolve the exception and restore it to previous working order.

@GOIII: I don't have the time to check, but I think T86235#976999 might be relevant for the Wikisource scripts (including the ProofreadPage extension and MediaWiki:Gadget-ocr.js) which add things to the old/classical toolbar. But it will probably require updates to the logic which decides which of the toolbars to use, and which modules are necessary...

See also:

@Krinkle I tried to submit a patch along your description. Can you do a code review?

Change 184127 merged by jenkins-bot:
Add dependency on mediawiki.toolbar

Krinkle assigned this task to Physikerwelt.
Krinkle removed a subscriber: gerritbot.