Last modified: 2014-11-17 10:35:30 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 T43489, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 41489 - ULS: JSON loading problems (Access-Control-Allow-Origin)
ULS: JSON loading problems (Access-Control-Allow-Origin)
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
UniversalLanguageSelector (Other open bugs)
master
All All
: Normal normal with 2 votes (vote)
: Future release
Assigned To: Nobody - You can work on this!
code-quality
:
Depends on:
Blocks: uls-deployment
  Show dependency treegraph
 
Reported: 2012-10-29 12:15 UTC by Krinkle
Modified: 2014-11-17 10:35 UTC (History)
15 users (show)

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


Attachments

Description Krinkle 2012-10-29 12:15:55 UTC
On: https://www.wikidata.org/wiki/Wikidata:Main_Page


[2x] XMLHttpRequest cannot load https://bits.wikimedia.org/static-1.21wmf2/extensions/UniversalLanguageSelector/lib/jquery.uls/i18n/en.json. Origin https://www.wikidata.org is not allowed by Access-Control-Allow-Origin.

[2x] XMLHttpRequest cannot load https://bits.wikimedia.org/static-1.21wmf2/extensions/UniversalLanguageSelector/i18n/en.json. Origin https://www.wikidata.org is not allowed by Access-Control-Allow-Origin.

ULS: Unknown language als. load.php:235
ULS: Unknown language bat-smg. load.php:235
ULS: Unknown language fiu-vro. load.php:235

[16x] XMLHttpRequest cannot load https://bits.wikimedia.org/static-1.21wmf2/extensions/UniversalLanguageSelector/i18n/en.json. Origin https://www.wikidata.org is not allowed by Access-Control-Allow-Origin.


* The extension documentation[1] contains nothing about requiring cross-domain privileges to work. If this is a requirement, then it must be documented and properly configured on Wikimedia (which it isn't right now)

* It repeatedly fails for the same stuff. 2x 2x for jquery.uls's en.json and a whopping 16 shots at the main en.json file. Whatever caching mechanism is in place, is broken. It probably doesn't cover for the fact that ajax is asynchronous (storing result objects instead of promises/deferreds)

* 3 requests for unknown languages


And all this when merely viewing an English page in an English browser without being logged-in before having touched anything on the page.

Should it be requesting all that data all the time? I suppose the trigger label in the top corner is provided by the MediaWiki component, it should defer further init until if/when needed.


[1] https://www.mediawiki.org/wiki/Extension:UniversalLanguageSelector
Comment 1 Santhosh Thottingal 2012-10-29 12:19:08 UTC
Bug 41454 tracks the 404s for non-localized(also failed requests) locales.
Comment 2 Niklas Laxström 2012-10-29 12:22:42 UTC
I could ask where is the documentation that says $wgExtensionAssetsPath (or whatever is used here) might be on another domain.

We need the Allow-Origin anyway for geoiplookup.
Comment 3 Sam Reed (reedy) 2012-10-29 18:08:00 UTC
Wikidata added to wgCrossSiteAJAXdomains
Comment 4 Krinkle 2012-10-29 18:15:59 UTC
(In reply to comment #2)
> I could ask where is the documentation that says $wgExtensionAssetsPath (or
> whatever is used here) might be on another domain.
> 

That's been a given since the start. Also, cross-domain shouldn't be an issue since CORS isn't supported by all browsers.

> We need the Allow-Origin anyway for geoiplookup.

No, not at all. How is that relevant? The Wikimedia geoiplookup uses javascript (not JSON) in a <script> tag, which isn't subject to Allow-Origin (just like loading jQuery from a CDN).

The geoiplookup that ULS uses by default uses JSONP (not cross-domain JSON, but JSONP, which isn't JSON but javascript calling a function).

This issue is not resolved, the 3 problems still exist (one of which is now resolved in modern browsers):

* Shouldn't require CORS.

* Shouldn't request the same json file 16 times.

* 3 requests for unknown languages (bug 41454).
Comment 6 Niklas Laxström 2012-11-01 13:08:57 UTC
Remaining issue is the one of allow-origin. Bug 25886 seems to be related to that.

Also added docs https://www.mediawiki.org/wiki/Extension:UniversalLanguageSelector#Configuration

What else needs to be done?
Comment 7 Andre Klapper 2012-11-12 01:32:40 UTC
(In reply to comment #6)
> Remaining issue is the one of allow-origin. Also added docs.
> What else needs to be done?

Could somebody answer this? Nikola / Krinkle?
Comment 8 Krinkle 2012-11-13 00:40:51 UTC
Well, bug 25886 isn't fixed yet, so this bug would still occur.

However I'd argue that we don't need ops to implement CORS on bits (bug 25886).

ULS shouldn't be using CORS to load JSON data from static files. It should use JSON-P, preferably from the API.
Comment 9 Krinkle 2012-11-13 00:41:09 UTC
(In reply to comment #8)
> Well, bug 25886 isn't fixed yet, so this bug would still occur.
> 
> However I'd argue that we don't need ops to implement CORS on bits (bug 25886).
> 
> ULS shouldn't be using CORS to load JSON data from static files. It should use
> JSON-P, preferably from the API.

Or from ResourceLoader.
Comment 10 Krinkle 2012-11-13 00:45:11 UTC
(In reply to comment #8)
> Well, bug 25886 isn't fixed yet, so this bug would still occur.
> 
> However I'd argue that we don't need ops to implement CORS on bits (bug 25886).
> 
> ULS shouldn't be using CORS to load JSON data from static files. It should use
> JSON-P, preferably from the API.

.. because CORS is only supported on modern browsers (ULS is currently breaking violating WMF browser compatibility guidelines), and it is a PITA to set up on caching servers (hence bug 25886).
Comment 11 Niklas Laxström 2012-11-13 11:02:35 UTC
(In reply to comment #8)
> ULS shouldn't be using CORS to load JSON data from static files. It should use
> JSON-P, preferably from the API.

As far as I know it is jquery.i18n which is loading the files. We are not going to change the i18n file format for this, so the ULS extension would need to implement custom loading wrapper for both backend and frontend.

Or perhaps we could just skip the effort and load the static files from the current domain ignoring bits altogether?
Comment 12 Andre Klapper 2012-12-05 17:07:42 UTC
This has been "highest priority" for five weeks now.
Does anybody actively work on this, or shall I bump this down?
Comment 13 Niklas Laxström 2012-12-05 17:46:32 UTC
I am waiting for further feedback on the two alternatives discussed in comment #11.
Comment 14 Krinkle 2012-12-06 07:37:07 UTC
(In reply to comment #11)
> (In reply to comment #8)
> > ULS shouldn't be using CORS to load JSON data from static files. It should use
> > JSON-P, preferably from the API.
> 
> As far as I know it is jquery.i18n which is loading the files. We are not
> going
> to change the i18n file format for this, so the ULS extension would need to
> implement custom loading wrapper for both backend and frontend.
> 
> Or perhaps we could just skip the effort and load the static files from the
> current domain ignoring bits altogether?

The wrapper sounds like the way to go. A simple ResourceLoader or API module. Which ever works best for you.

API:

 Implement:
  GET /api.php?action=<module>&lang=<lang>&callback=..
  ...({...data from json file..});

 Load:
  $.getJSON(api, function (data) {
    mw.ext.uls.provideLang(data);
  });

ResourceLoader:

 Implement:
  register module (if you only ever need 1 lang per page, switch getScript response based on context language within 1 module, or register 1 module per language)
  module's getScript would be like mw.ext.uls.provideLang({...data from json file..});

 Load:
  mw.loader.load( '<module>.<lang>' );


The API approach is probably better. It gives more flexibility in usage (by providing the data directly from the callback) and doesn't fill the startup module with 1 lot of modules for every language code.
Comment 15 Andre Klapper 2013-01-02 13:01:10 UTC
Niklas: Requested feedback provided in comment 14.
Do you either plan to fix this, or instead lower priority? Thanks.
Comment 16 Andre Klapper 2013-01-23 20:48:51 UTC
Niklas: This is highest priority for quite some weeks now. Do you have a potential assignee in mind? Could you answer comment 15?
Comment 17 Niklas Laxström 2013-01-24 09:35:23 UTC
I'm not planning to work on this in nearest future unless if it assigned to me in a sprint planning.
Comment 18 Siebrand Mazeland 2013-02-11 11:43:05 UTC
Decreased priority. Nothing's on fire.
Comment 19 Santhosh Thottingal 2013-05-21 08:29:00 UTC
(In reply to comment #14)
> > (In reply to comment #8)
> > Or perhaps we could just skip the effort and load the static files from the
> > current domain ignoring bits altogether?
> 
> The wrapper sounds like the way to go. A simple ResourceLoader or API module.
> Which ever works best for you.

Krinkle, is there a problem if we directly load the static json files from the current domain? What is the advantage of having a wrapper(RL or API) that reads the json files and serve here?
Comment 20 Andre Klapper 2013-05-29 12:50:35 UTC
Krinkle: ping - Could you answer comment 19 please?
Comment 21 Santhosh Thottingal 2013-06-07 08:08:58 UTC
API was written to load the json in I37638e06f21ab573c9ce37a4e9fb20bc763ac98f.

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


Navigation
Links