Last modified: 2013-04-22 16:14:48 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T44926, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 42926 - mwEmbed overwrites jquery.ui.autocomplete (JavaScript)
mwEmbed overwrites jquery.ui.autocomplete (JavaScript)
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
TimedMediaHandler (Other open bugs)
unspecified
All All
: Unprioritized major (vote)
: ---
Assigned To: Michael Dale
: code-update-regression
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-10 22:08 UTC by Rainer Rillke @commons.wikimedia
Modified: 2013-04-22 16:14 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Rainer Rillke @commons.wikimedia 2012-12-10 22:08:56 UTC
Activation of mwEmbed at Wikimedia Commons leads to some bugs. Therefore, I call it a regression. Writing this bug report presumably took me more time than fixing the bug but if I don't get dev-access, it's not my problem.

Browsers: all.
OS: all.

Error symptoms:
jquery.ui.autocomplete ([f1] https://bits.wikimedia.org/static-1.21wmf5/resources/jquery.ui/jquery.ui.autocomplete.js ) does not work when used on a page with video

Exact error message:
"this.menu is undefined"

But this is only the symptom. The error happens before: While creating the autocomplete, the wrong "menu" is created. The mw-embed menu (see below) does not assign a "data" attribute. So calling .data( "menu" ) [cf. l. 208, f1] will return undefined to this.menu [cf. l. 131, f1] in the _create method of jquery.ui.autocomplate. It won't immediately throw an error. But when the jQuery autocomplete is used the first time...

Reason:
On pages with embedded videos, mw-embed is loaded. mw-embed contains a module "jquery.menu"
Confer to:
[f2] https://bits.wikimedia.org/static-1.21wmf5/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.menu/jquery.menu.js
Evidence: (l.61) "$.fn.menu = function( options ) {"

This overwrites the native jQuery "menu" implementation in jQuery autocomplete:
[f1] https://bits.wikimedia.org/static-1.21wmf5/resources/jquery.ui/jquery.ui.autocomplete.js
Evidence: (l.468) "$.widget("ui.menu", {"

$.fn.menu now points to the mw-embed menu. 
After mw-embed is loaded, all autocomplete-enhanced inputs will throw errors. No autocomplete will be shown.
NOTE THAT THE ORDER IN WHICH THE MODULES WERE LOADED, IS ESSETIALLY IMPORTANT WHEN TRYING TO REPRODUCE THIS BEHAVIOUR. I recommend activating a gadget, which has a dependency to jquery.ui.autocomplate (like cat-a-lot) when you try to reproduce it. This will likely load jquery.ui.autocomplate before mw-embed. YOU MUST TEST IT ON A PAGE WITH EMBEDDED VIDEO. Then simply create an autocomplete according to http://jqueryui.com

I tested it with Cat-A-Lot enabled in my prefs at 
https://commons.wikimedia.org/wiki/Commons:Forum?useskin=vector&debug=true&withJS=MediaWiki:VisualFileChange.js

Expected behaviour:
mw-embed does not interfere with jQuery's native stuff.

FixIt:
Please rename "$.fn.menu = function( options ) {" in mw-embed to something different e.g. "$.fn.embedMenu"
Comment 1 Jan Gerber 2012-12-11 10:25:03 UTC
MwEmbedSupport part
https://gerrit.wikimedia.org/r/#/c/38045/

TimedMediaHandler part
https://gerrit.wikimedia.org/r/#/c/38046/

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links