Page MenuHomePhabricator

VisualEditor: [Regression wmf13] TypeError: Cannot read property 'context' of undefined appears when you try to insert another image that appears on the same index as the previous search, right after you inserted one
Closed, ResolvedPublic

Description

Steps to reproduce:

1.Open a page with VE
2.Go to Insert>Media
3.Enter a search term
4.Select the first image that appears on the search result
4.Click on Change image immediately
5.Enter a different search term
6.Now try to select the first image on of the new search results

Observed Result:
It throws an error:Uncaught TypeError: Cannot read property 'context' of undefined

and cannot select that image


Version: unspecified
Severity: normal

Details

Reference
bz67749

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:31 AM
bzimport set Reference to bz67749.

This seems to be the same jQuery/API issue we've had with calling the mw API consecutively. When the API is queried more than once the callback function goes haywire.

In debug mode when clicking the 'change image' (#4 in the above reproduce list), the console error is

"Uncaught TypeError: undefined is not a function"
api.php?callback=jQuery111109575085956603289_1404944903047&format=json&uselang=en&action=query&gene…:1

Change 150054 had a related patch set uploaded by Mooeypoo:
MWMediaSearchWidget: Use json/jsonp for local/foreign api respectively

https://gerrit.wikimedia.org/r/150054

Change 150054 merged by jenkins-bot:
MWMediaSearchWidget: Use json/jsonp for local/foreign api respectively

https://gerrit.wikimedia.org/r/150054

(In reply to Moriel Schottlender from comment #1)

This seems to be the same jQuery/API issue we've had with calling the mw API
consecutively. When the API is queried more than once the callback function
goes haywire.

In debug mode when clicking the 'change image' (#4 in the above reproduce
list), the console error is

"Uncaught TypeError: undefined is not a function"
api.
php?callback=jQuery111109575085956603289_1404944903047&format=json&uselang=en
&action=query&gene…:1

That undefined function error is not related in any way, that's bug 59604.

When I tried to reproduce this bug (before the merge of the above fix), I kept getting this error in chrome:

Uncaught TypeError: undefined is not a function commons.wikimedia.org/w/api.php?callback=jQuery1111024360889615491033_14067…set=0&prop=imageinfo&iiprop=dimensions%7Curl%7Cmediatype&iiurlheight=150:1

And this in in firefox

TypeError: jQuery111109862733512069084_1406742881657 is not a function

/**/jQuery111109862733512069084_1406742881657({"warnings":{"main":{"*":"Unrecogn...

And only after that I get an 'uncaught type error' that seems to be related to missing details in the image (like the caption document). It only happens right after the first API bug. I wasn't able to reproduce it after the 150054 fix was introduced.

The API response just before the bug appears seems to suggest that the information from the API is maybe mismatch to the loaded image, which is why I thought it was related.

The bug doesn't happen with this fix anymore (I can't reproduce it in master or in beta labs now that it's merged)

Verified the fix in production