Page MenuHomePhabricator

Link search function is invalid in VisualEditor on zh.wikipedia.org (due to local MediaWiki:Common.js/edit.js)
Closed, InvalidPublicBUG REPORT

Description

Steps to Reproduce:

  1. Open any Chinese article under VisualEditor.
  2. Highlight any word and key "Ctrl + K"

Actual Results:
No searching result was displayed.

Expected Results:
Able to display the matched article in website.

Event Timeline

Uncaught TypeError: Cannot read property 'replace' of undefined
    at parse (<anonymous>:442:810)
    at new Title (<anonymous>:444:501)
    at MwWidgetsTitleSearchWidget.mw.widgets.TitleWidget.getOptionWidgetData (<anonymous>:276:874)
    at MwWidgetsTitleSearchWidget.mw.widgets.TitleWidget.getOptionsFromData (<anonymous>:276:619)
    at <anonymous>:281:751
    at fire (load.php?lang=zh&modules=ext.quicksurveys.init|ext.uls.compactlinks|jquery%2Coojs-ui-core%2Coojs-ui-widgets|jquery.ui|mediawiki.ui.button&skin=vector&version=hjs7u:55)
    at Object.add [as done] (load.php?lang=zh&modules=ext.quicksurveys.init|ext.uls.compactlinks|jquery%2Coojs-ui-core%2Coojs-ui-widgets|jquery.ui|mediawiki.ui.button&skin=vector&version=hjs7u:55)
    at MwWidgetsTitleSearchWidget.mw.widgets.TitleSearchWidget.onQueryChange (<anonymous>:281:589)
    at OoUiSearchInputWidget.OO.EventEmitter.emit (<anonymous>:334:483)
    at OoUiSearchInputWidget.OO.ui.InputWidget.setValue (load.php?lang=zh&modules=ext.quicksurveys.init|ext.uls.compactlinks|jquery%2Coojs-ui-core%2Coojs-ui-widgets|jquery.ui|mediawiki.ui.button&skin=vector&version=hjs7u:282)

The cause of this error is the method Array.prototype.intersects defined in https://zh.wikipedia.org/wiki/MediaWiki:Common.js/edit.js. When you define a method like this, it appears as if it was an array element when iterating using for ( … in … ), which then causes confusing exceptions. The easiest way to fix it would be to change it to a local method (it doesn't appear to be used outside of that file).

Aklapper renamed this task from Link search function is invalid in Chinese VisualEditor. to Link search function is invalid in VisualEditor on zh.wikipedia.org (due to local MediaWiki:Common.js/edit.js).May 11 2020, 5:32 PM
Aklapper added a project: Chinese-Sites.
Xiplus subscribed.

Fixed (diff). I removed the method.