Page MenuHomePhabricator

When both twinkle and mwEmbed are enabled, mwEmbed errors out.
Closed, ResolvedPublic

Details

Reference
bz24268

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:00 PM
bzimport set Reference to bz24268.

Nx.devnull wrote:

The problem is this:

var moduleRequestSet = [];
...
for(var moduleName in moduleRequestSet) { ... }

This works fine as long as no-one touches Array.prototype, but Twinkle adds three new functions, which results in mwEmbed trying to load a nonexistent module called "uniq".

The solution in this case should be as simple as changing the declaration to var moduleRequestSet = {};, but that still doesn't protect against someone messing with Object.prototype, and it won't allow you to use the Array type's functions, e.g. push.

It might be a better idea to use something like Prototype's Hash.

mdale wrote:

Scripts should not extend base object prototypes! .. But to the extent this can be worked around I use for( i = 0; array.length; i++ ) for arrays. If a script extends the base "Object" prototype that will be complicated to work around and slow everything down since every for loop in the entire codebase would have to check the property types instance variables and or use function heavy jQuery.each(object, function(inx, item){ /*..*/ }); iterator, which is a lot of overhead for some of loops that need to be fast.

fixed in r69064