Page MenuHomePhabricator

Changes to TemplateData not applied when using the TemplateData GUI, unless in safe mode
Closed, InvalidPublic

Description

@DePiep reports that the "Manage TemplateData" tool is not working in either Chrome v69 64-bit or Firefox 62 on Windows 10. Since ?safemode=1 resolves the problem, this may be due to a user script or gadget.

https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#Managing_TemplateData%3A_does_not_write_my_edits

Testing process

  1. Clear cache
  2. Open Template:See_also/doc (read)
  3. add ?safemode=1 to end of URL
  4. open for Edit (with me, traditional edit mode, not VE). The appendix ?safemode=1 did not return, so:
  5. add &safemode=1 to action=edit URL(needs &) and reload, opens:
  6. https://en.wikipedia.org/w/index.php?title=Template:See_also/doc&action=edit&safemode=1 (edit screen, looks OK)
  7. Open Manage TemplateData (button)
  8. Add paramter, paramter "Test"; Apply;
  9. Done, parameter added [5] (success).
  10. Same for Template:Currency/doc (success when using &safemode=1).
  11. After both successes, tried again without safemode: failed in both pages.

Running with debug=true, webconsole message in Chrome: "Uncaught TypeError: Cannot read property 'accessKey' jquery.js[...]" (in Firefox: "jQuery.Deferred exception: element is undefined [...]").

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Notes:

  • Visual Editor not involved (edits are tried in classic WP edit box)
  • When *not* logged in: test success (no bug).
  • Issue also appears with non-protected pages (namespace template).

Running with debug=true, webconsole message in Chrome: "Uncaught TypeError: Cannot read property 'accessKey' jquery.js[...]" (in Firefox: "jQuery.Deferred exception: element is undefined [...]"). Need more? -DePiep (talk) 16:17, 10 October 2018 (UTC)

So I'm guessing that the error comes from a line of code like element.accessKey. The only place where we have an expression like this is in jquery.accessKeyLabel in MW core. Looks like some code is trying to set or get the accesskey of some element, but passing undefined instead. But it seems unfeasible to find out which code does this without a backtrace. $(…).updateTooltipAccessKeys is used all over the place.

the stack:

JQMIGRATE: Migrate is installed with logging active, version 3.0.1
load.php?debug=true&lang=en&modules=startup&only=scripts&skin=vector:439 Use of "importScriptURI" is deprecated. Use mw.loader instead.
maybeLog @ load.php?debug=true&lang=en&modules=startup&only=scripts&skin=vector:439
arrow-expanded.svg:1 Failed to load resource: the server responded with a status of 404 ()
4load.php?debug=true&lang=en&modules=startup&only=scripts&skin=vector:439 Use of "mw.toolbar" is deprecated.
maybeLog @ load.php?debug=true&lang=en&modules=startup&only=scripts&skin=vector:439
jquery.migrate.js?cacf7:90 JQMIGRATE: jQuery.fn.bind() is deprecated
migrateWarn @ jquery.migrate.js?cacf7:90
jquery.js?6a07d:3818 jQuery.Deferred exception: Cannot read property 'accessKey' of undefined TypeError: Cannot read property 'accessKey' of undefined

at Function.getAccessKeyLabel (https://en.wikipedia.org/w/resources/src/jquery/jquery.accessKeyLabel.js?59bf7:111:17)
at OoUiTextInputWidget.OO.ui.mixin.AccessKeyedElement.formatTitleWithAccessKey (https://en.wikipedia.org/w/resources/lib/ooui/oojs-ui-core.js?fd88e:3593:44)
at OoUiTextInputWidget.OO.ui.mixin.TitledElement.updateTitle (https://en.wikipedia.org/w/resources/lib/ooui/oojs-ui-core.js?fd88e:3440:18)
at OoUiTextInputWidget.OoUiMixinAccessKeyedElement (https://en.wikipedia.org/w/resources/lib/ooui/oojs-ui-core.js?fd88e:3500:8)
at OoUiTextInputWidget.OoUiInputWidget (https://en.wikipedia.org/w/resources/lib/ooui/oojs-ui-core.js?fd88e:8669:33)
at new OoUiTextInputWidget (https://en.wikipedia.org/w/resources/lib/ooui/oojs-ui-core.js?fd88e:10102:31)
at Object.OO.ui.Element.static.unsafeInfuse (https://en.wikipedia.org/w/resources/lib/ooui/oojs-ui-core.js?fd88e:831:8)
at Object.OO.ui.Element.static.infuse (https://en.wikipedia.org/w/resources/lib/ooui/oojs-ui-core.js?fd88e:697:33)
at Object.OO.ui.infuse (https://en.wikipedia.org/w/resources/lib/ooui/oojs-ui-core.js?fd88e:341:30)
at HTMLDocument.<anonymous> (https://en.wikipedia.org/w/resources/src/mediawiki.action/mediawiki.action.edit.js?8dedd:23:22) undefined

jQuery.Deferred.exceptionHook @ jquery.js?6a07d:3818
jquery.js?6a07d:3827 Uncaught TypeError: Cannot read property 'accessKey' of undefined

at Function.getAccessKeyLabel (jquery.accessKeyLabel.js?59bf7:111)
at OoUiTextInputWidget.OO.ui.mixin.AccessKeyedElement.formatTitleWithAccessKey (AccessKeyedElement.js:135)
at OoUiTextInputWidget.OO.ui.mixin.TitledElement.updateTitle (TitledElement.js:106)
at OoUiTextInputWidget.OoUiMixinAccessKeyedElement (AccessKeyedElement.js:42)
at OoUiTextInputWidget.OoUiInputWidget (InputWidget.js:43)
at new OoUiTextInputWidget (TextInputWidget.js:66)
at Object.OO.ui.Element.static.unsafeInfuse (Element.js:241)
at Object.OO.ui.Element.static.infuse (Element.js:107)
at Object.OO.ui.infuse (core.js:327)
at HTMLDocument.<anonymous> (mediawiki.action.edit.js?8dedd:23)
matmarex claimed this task.

I spent a few hours investigating this today. The problem with TemplateData editor and the exception are actually two separate issues, but both are caused by the wikEd gadget. @DePiep I am guessing you're using it since you have some configuration for it in your vector.js page.


The original issue with the TemplateData editor has actually been reported in the past, as far back as 2014: T73363.

The solution is for TemplateData to use the jquery.textSelection API to make changes to the wikitext, and for wikEd to implement the jquery.textSelection API to respond to them and update its syntax-highlighted editing area. The TemplateData part has been done a few months ago when T73363 was resolved (better late than never, heh).

You will need to report this problem to wikEd's maintainers on its talk page, so that they can do the wikEd part. Here's an example showing how CodeMirror (the default syntax-highlighting tool) implements this API:


The exception and stack trace is actually unrelated to the original issue, although it is also caused by wikEd.

The exception is thrown in mediawiki.action.edit.js when it tries to add a counter of remaining characters to the edit summary input (it is shown when you have less than 100 left), but the edit summary input doesn't exist because wikEd has removed it and inserted its own elsewhere. As a result, the character counter is not added (which is not a big issue in this case, since wikEd removes the entire field).

You'll also need to report this problem to wikEd's maintainers. I think the easiest workaround would be to add a dependency from wikEd on the 'mediawiki.action.edit' module, so that it always loads first (the exception doesn't happen when they run in this order, only if wikEd runs first).