Page MenuHomePhabricator

mwCustomEditButtons broken: edit toolbar does not update if site JS is slow to load
Closed, ResolvedPublic

Description

On the English Wikipedia, the old edit toolbar sometimes shows only the default buttons. The buttons which are added by [[MediaWiki:Common.js/edit.js]] with mwCustomEditButtons.push() are not shown.

Testing with Firebug supports the theory that this is due to mediawiki.toolbar.onReady() being called before [[MediaWiki:Common.js/edit.js]] finishes loading (it is loaded with importScript()).


Version: 1.19
Severity: normal

Details

Reference
bz35077

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 12:20 AM
bzimport set Reference to bz35077.
bzimport added a subscriber: Unknown Object (MLST).

Adding CCs for Roan and Krinkle, I'm hoping I can avoid having to fix this one myself.

Didn't we solve this already?

The global array can't be trusted, never could and never can. It's looked at once at a certain point (when onReady fires) and after that it's gone. Therefor mw.toolbar.addButton was introduced.

user scripts and site scripts do load before onReady afaik (otherwise mwCustomEditButtons wouldn't work at all). But this one is called through importScript from MediaWiki:Common.js, separate http request.

I'm not sure what else we can do about this. Changing the script to use mw.toolbar.addButton will fix it.

There's a catch in this particular case though. The items added to the array on [[MediaWiki:Common.js/edit.js]] are not intended to be added to the toolbar per se.
It's depending on the ability for the user script to clear the array, however this hasn't worked stability for quite a while.

In general using mw.toolbar.addButton fixes it, but in this particular case that's not a solution, but that's a problem with that script and a use case I don't think can be expected to work.

I've posted 2 suggestions on that talk page: https://en.wikipedia.org/wiki/MediaWiki_talk:Common.js/edit.js#MediaWiki:Common.js.2Fedit.js:_mw.toolbar.addButton

https://en.wikipedia.org/wiki/MediaWiki_talk:Common.js/edit.js#MediaWiki:Common.js.2Fedit.js:_Opt-out

  • This bug has been marked as a duplicate of bug 31511 ***