Last modified: 2007-02-03 21:59:07 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 T8684, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 6684 - Improper javascript array iteration causes problems
Improper javascript array iteration causes problems
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.8.x
All All
: Low minor with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-reviewed
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-07-14 20:08 UTC by Christian Neubauer
Modified: 2007-02-03 21:59 UTC (History)
0 users

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


Attachments
Patch for wikibits.js fixing protoype incompatibility (568 bytes, patch)
2006-08-14 00:16 UTC, Dan Li
Details

Description Christian Neubauer 2006-07-14 20:08:56 UTC
In wikibits.js on line 367 or so, there are two for loops that use the for..in
mechanism to loop through arrays.  Since these are arrays and not objects they
should be looped through using plain for loops.  Using for..in causes problems
when you include javascript libraries like older versions of prototype that mess
with Object.prototype.

To see the fun bugs it causes, try including prototype in your skin and look at
the edit toolbar.

To fix this, change:
  for(i in mwEditButtons) {
to:
  for (var i = 0; i < mwEditButtons.length; i++) {

and:
  for(i in mwCustomEditButtons) {
to:
  for (var i = 0; i < mwCustomEditButtons.length; i++) {

For further information about properly iterating arrays in javascript see:
http://simon.incutio.com/slides/2006/etech/javascript/js-reintroduction-notes.html#arrays
Comment 1 Dan Li 2006-08-11 23:09:30 UTC
Just wanted to say that I had to do the same, with the latest version of prototype.

By the way, this isn't because prototype messes with Object, but because it
messes with Array. (For example, the for...in loop on line 470 works fine
because ta is an Object, not an Array.)
Comment 2 Dan Li 2006-08-14 00:16:25 UTC
Created attachment 2222 [details]
Patch for wikibits.js fixing protoype incompatibility

Not sure how things work around here...is a diff easier to commit than
scrolling to line 369?
Comment 3 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-08-14 00:17:35 UTC
Attached patches should generally be in unified diff format.  If a dev would
prefer to just manually scroll to the right lines, they can do that too.
Comment 4 Dan Li 2006-08-14 00:20:21 UTC
> Attached patches should generally be in unified diff format.

Was my attachment in the right format?
Comment 5 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-08-14 00:21:08 UTC
Yes.
Comment 6 Antoine "hashar" Musso (WMF) 2007-02-03 21:59:07 UTC
Thanks for the patch Dan.

Applied in r19744.

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


Navigation
Links