Last modified: 2010-06-06 20:04:05 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 T25809, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 23809 - mwEmbed is hard to debug
mwEmbed is hard to debug
Status: RESOLVED FIXED
Product: mwEmbed
Classification: Unclassified
Script loader (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Michael Dale
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-05 20:31 UTC by Platonides
Modified: 2010-06-06 20:04 UTC (History)
0 users

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


Attachments

Description Platonides 2010-06-05 20:31:11 UTC
mwEmbed flow is too complex.

http://prototype.wikimedia.org/mwe-gadget/mwEmbed/remotes/mediaWiki.js calls AddMediaWizardEditPage.js or uploadPage.js or apiProxyPage.js or mwEmbed.js, scattered through the file, via loadMwEmbed which produce a call for a url like /mwe-gadget/mwEmbed/jsScriptLoader.php?class=window.jQuery,mwEmbed,mw.UploadHandler,mw.UploadInterface,mw.Firefogg,$j.ui,$j.ui.progressbar,$j.ui.dialog,$j.ui.draggable&uselang=es&urid=r127 almost impossible to find, not to mention that it's minified and it's not obvious that you can add &debug=true to unminify it (in fact, I had to search the option at the source).
Comment 1 Michael Dale 2010-06-06 03:42:13 UTC
Thanks for looking into mwEmbed. Is there somewhere else you looked for the documentation that I should add documentation links to? Or maybe a link inside the comments of the gadget? 

The gadget mode for mwEmbed is somewhat complex since it does a few tricks to  minimize round trips and package size. All the module gadgets share a common "remote" for efficient and easy to manage page rewrites for multiple usage contexts. ( en, commons, other language encyclopedias etc. ) 

I have targeted most documentation towards extension based use of the framework and modules. You can see some extension documentation about JS2 on the js2 page: http://www.mediawiki.org/wiki/JS2_Overview  Do you think more gadget usage documentation would be helpful? If so I can work on improving that. 

The gadget modules share the same code used in extensions, and in the extension context it never touches the mediaWiki remote file. As an extension the php includes the appropriate "activator" code ( AddMediaWizardEditPage.js or uploadPage.js etc.  )  The activators then load the modules on demand with context specific configuration. This lets modules be re-used in different contexts with different configuration options, while not sacrificing performance in extra round trips to the server, or downloading unnecessary code. We want to promote a "clean separation of configuration, invocation binding and interface code" while optimizing for reusable client cache and high perceived page performance.  


In terms of "development" or debugging in the remote "gadget" mode ... I can quickly share how I work on it and how it can be much more friendly to development debugging once your in "develop mode". 

1) You will want to-switch away from using the script that is served from the prototype server to a version you check out to local web server. you can check out the code from 
http://svn.wikimedia.org/svnroot/mediawiki/branches/MwEmbedStandAlone/

Disable the gadget and reference the script in your user js file. ie something like http://commons.wikimedia.org/wiki/User:Mdale/vector.js

2) You will want to include the "debug" in the url parameter. as of r67420 debug param also disables script-grouping so you get direct reference to all the javascript and css files. 

3) Now you should be able to directly modify the scripts in your code editor and run it directly on commons or en wiki.
Comment 2 Platonides 2010-06-06 15:34:55 UTC
Hello Michael,
I realise this a consecuence of those tricks, so it is hard to make simple.

On bug 23808 I only saw that some javascript was adding something wrong. Commons has a lot of custom javascript, and the only tip to identify which to blame was the text "For improved uploads".
So I stated looking at eit.js, upload.js, htmlform.js, MediaWiki:Upload.js... to make things harder, some strings come from a /lang url, I also searched along the MediaWiki namespace and Special:Allmessages.

I finally launched a sniffer, that's how I found the jsScriptLoader.php?class=window.jQuery,mwEmbed,mw.UploadHandler,mw.UploadInterface,mw.Firefogg,$j.ui,$j.ui.progressbar,$j.ui.dialog,$j.ui.draggable url where the string was (between a lot of gobbledigook :).

I was just looking for who was adding the text, so I ended there. If I was going to actually coding something related to it, I think a comment at the top of the minified file would have been convenient: a note about debug=true, or perhaps a url on how to debug it, where the debug=true and other tricks can be shared without space constraints.
Comment 3 Michael Dale 2010-06-06 20:04:05 UTC
oky added some documentation to http://www.mediawiki.org/wiki/JS2_Overview#Debugging_mwEmbed_Gadget

And added links to that documentation as comments in the gadgets on both en and commons.

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


Navigation
Links