Page MenuHomePhabricator

CodeMirror load breaks at $button.toggleClass(...)
Closed, ResolvedPublic

Description

CodeMirror breaks JavaScript on load in ext.CodeMirror.js: line 187:3 with:

load.php?debug=false&lang=en&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1faydix:52 Uncaught TypeError: $button.toggleClass(...).data(...) is not a function
    at updateToolbarButton (load.php?debug=false&lang=en&modules=ext.CodeMirror|ext.CodeMirror.data%2Clib|ext.CodeMirror.mode.mediawiki|ext.centralauth.centralautologin.clearcookie|ext.echo.api%2Cinit|ext.math.editbutton.enabler|ext.wikimediaEvents.loggedin|jquery.tipsy|mediawiki.action.edit.preview|mediawiki.api.messages|mediawiki.diff.styles|mediawiki.page.watch.ajax|oojs-ui-core%2Csite&skin=vector&version=089p435:4)
    at HTMLDocument.<anonymous> (load.php?debug=false&lang=en&modules=ext.CodeMirror|ext.CodeMirror.data%2Clib|ext.CodeMirror.mode.mediawiki|ext.centralauth.centralautologin.clearcookie|ext.echo.api%2Cinit|ext.math.editbutton.enabler|ext.wikimediaEvents.loggedin|jquery.tipsy|mediawiki.action.edit.preview|mediawiki.api.messages|mediawiki.diff.styles|mediawiki.page.watch.ajax|oojs-ui-core%2Csite&skin=vector&version=089p435:6)
    at mightThrow (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1faydix:49)
    at process (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1faydix:50)

(tested in Firefox and Chrome on Commons)

Event Timeline

Perhelion created this task.Jun 5 2018, 8:38 PM
Restricted Application added a project: Community-Tech. · View Herald TranscriptJun 5 2018, 8:38 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Perhelion updated the task description. (Show Details)Jun 5 2018, 8:50 PM
Perhelion updated the task description. (Show Details)Jun 5 2018, 8:54 PM
MusikAnimal added a subscriber: MusikAnimal.EditedJun 5 2018, 9:03 PM

I'm not able to reproduce. Try editing a page in safemode by adding safemode=1 in the URL, for instance (random file): https://commons.wikimedia.org/w/index.php?title=File:Redmire_Farm_Sheepfold_-_geograph.org.uk_-_1713413.jpg&action=edit&section=1&safemode=1

Do you still see the error? If not the issue may be with an unrelated script.

@MusikAnimal: Yes I still see the error. In addition I have to say that it only occurs when the classic toolbar (which will be removed soon from core) is used or the Wikieditor is disabled.

MusikAnimal added a comment.EditedJun 6 2018, 3:08 AM

Got it. I can now reproduce as well. Not sure what the issue is, but indeed only 2003 and 2006 editors are affected.

I have got this error message when I click edit.
Error:
https://commons.wikimedia.org/w/load.php?debug=false&lang=en-gb&modules=ext.3d%2CCodeMirror%2Ccharinsert%2CeventLogging%2CnavigationTiming%2CwikimediaEvents%7Cext.CodeMirror.data%2Clib%7Cext.CodeMirror.mode.mediawiki%7Cext.centralNotice.geoIP%7Cext.centralauth.ForeignApi%7Cext.centralauth.centralautologin.clearcookie%7Cext.echo.api%2Cinit%7Cext.eventLogging.subscriber%7Cext.math.editbutton.enabler%7Cext.uls.common%2Ccompactlinks%2Ceventlogger%2Cinit%2Cinterface%2Cpreferences%2Cwebfonts%7Cext.visualEditor.desktopArticleTarget.init%7Cext.visualEditor.supportCheck%2CtargetLoader%2CtempWikitextEditorWidget%2Ctrack%2Cve%7Cext.wikimediaEvents.loggedin%7Cjquery.accessKeyLabel%2CcheckboxShiftClick%2Cclient%2Ccookie%2CgetAttrs%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Cspinner%2Csuggestions%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.uls.data%7Cmediawiki.ForeignApi%2CRegExp%2CString%2CTitle%2CUri%2Capi%2Ccldr%2CconfirmCloseWindow%2Ccookie%2Cexperiments%2Cicon%2CjqueryMsg%2Clanguage%2Cnotify%2CsearchSuggest%2Cstorage%2Ctemplate%2Ctoolbar%2Cuser%2Cutil%7Cmediawiki.ForeignApi.core%7Cmediawiki.action.edit%7Cmediawiki.action.edit.collapsibleFooter%2CeditWarning%7Cmediawiki.api.options%7Cmediawiki.language.data%2Cinit%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%2Cstartup%7Cmediawiki.page.watch.ajax%7Cmediawiki.template.regexp%7Cmediawiki.ui.button%2Cicon%7Cmediawiki.widgets.visibleLengthLimit%7Cmmv.bootstrap%2Chead%7Cmmv.bootstrap.autostart%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csite%7Coojs-ui-widgets.styles%7Coojs-ui.styles.icons-editing-advanced%2Cicons-editing-styling%2Cicons-moderation%2Cicons-movement%7Cschema.UniversalLanguageSelector%7Cskins.monobook.mobile%7Cskins.monobook.mobile.echohack%2Culs%7Cuser.defaults%7Cwikibase.client.action.edit.collapsibleFooter&skin=monobook&version=18p7hi5 at line 6: TypeError: $button.toggleClass(...).data(...) is not a function

TheDJ added a subscriber: TheDJ.Jun 17 2018, 8:37 PM

Ah, I found this too.

This is https://github.com/wikimedia/mediawiki-extensions-CodeMirror/blob/master/resources/ext.CodeMirror.js#L194
.data( 'setActive' ) returns undefined if you have the old style wiki toolbar instead of WikiEditor 2010 (enhanced toolbar) enabled.

See also change in: https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/CodeMirror/+/440761/1/resources/ext.CodeMirror.js

TheDJ triaged this task as Low priority.Jun 17 2018, 8:37 PM

Hello,

There is a problem on frwiki that seems similar to the problem described here.

When the old toolbar is used on preferences, the extra buttons added by gadgets to the old style toolbar are not functional (they produce no effect).

This problem only occurs when CoreMirror is enabled. Whenever CodeMirror is enabled (or disabled) in the editor, this error message appears on the JS console:

TypeError: $button.toggleClass(...).data(...) is not a function load.php:6:700

This problem has been reported on the frwiki village pump :
https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Le_Bistro/18_juin_2018#Coloration_syntaxique_:_suite_et_probl%C3%A8me

(sorry for my bad english)

Change 440761 had a related patch set uploaded (by MusikAnimal; owner: TheDJ):
[mediawiki/extensions/CodeMirror@master] Accessibility: mark syntaxhighlight button as a switch

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

Change 440761 merged by jenkins-bot:
[mediawiki/extensions/CodeMirror@master] Accessibility: mark syntaxhighlight button as a switch

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

matmarex closed this task as Resolved.Jun 18 2018, 5:24 PM
matmarex assigned this task to TheDJ.
matmarex removed a project: Patch-For-Review.
matmarex added a subscriber: matmarex.
Vvjjkkii renamed this task from CodeMirror load breaks at $button.toggleClass(...) to nkbaaaaaaa.Jul 1 2018, 1:05 AM
Vvjjkkii reopened this task as Open.
Vvjjkkii removed TheDJ as the assignee of this task.
Vvjjkkii raised the priority of this task from Low to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed subscribers: gerritbot, Aklapper.
CommunityTechBot renamed this task from nkbaaaaaaa to CodeMirror load breaks at $button.toggleClass(...) .Jul 2 2018, 4:40 AM
CommunityTechBot closed this task as Resolved.
CommunityTechBot assigned this task to TheDJ.
CommunityTechBot lowered the priority of this task from High to Low.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added subscribers: gerritbot, Aklapper.