Page MenuHomePhabricator

Cross-wiki API
Closed, DeclinedPublic

Description

It should be possible to e.g. query the French wiki through the English wiki API, like

en.wikipedia.org/w/api.php?interwiki=fr&action=query&...

This is needed for scripts using XHR, which can't go off-domain. An implementation should preferably add a table mapping interwiki prefixes to api.php URLs (maybe use the existing interwiki table for this?), then kind of forward the request by acting as a proxy (send an HTTP request to fr.wikipedia.org and spitting the output back out to the user). 302 and friends probably (?) won't work here (XHR's gotta be smarter than that).


Version: unspecified
Severity: enhancement

Details

Reference
bz14024

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:10 PM
bzimport set Reference to bz14024.

I'm a bit leery of this for several reasons:

  • authentication
  • private wikis
  • backend issues (are they hosted together, etc)

(In reply to comment #1)

I'm a bit leery of this for several reasons:

  • authentication

Yeah, this could get nasty with passing cookies around and stuff like that.

  • private wikis
  • backend issues (are they hosted together, etc)

I see no problem there. The first wiki just forwards the request to the second wiki, and the second wiki's api.php decides what to output (whether the user has the needed rights, etc.)

I don't think one api.php should call another api.php.

This would probably be better handled with a column for storing an api url for an interwiki if that interwiki site is a MediaWiki site and does have an api.

And so the client could query the interwiki tables to know of any other API's that they can access. If there is one for the interwiki they queried for, then they can query from that API.

The Client shouldn't be using the API as a proxy, that's what we have JSON callback support for.

Dunno why I made this depend on bug 14418, we need a schema change to the interwiki table here, not to the redirect table.

To implement this, we'd need an iw_api field in the interwiki table containing the URL of the wiki's api.php

Preliminary implementation. Needs a lot of work still (output needs formatting, so setReturnType() actually _does_ something). However, it does work :-)

Created attachment 5206
Basic implementation

Ignore the previous comment *smack*.

Basic implementation works in this patch. Ran some basic test queries against enwiki and got the results I was expecting. Needs the cleanup I mentioned above.

Attached:

  • Bug 15469 has been marked as a duplicate of this bug. ***

Bryan.TongMinh wrote:

I don't really see a particular use for this. If you want ot bypass Javascript's same origin policy, you could as well use the document.write hack. Is there another use for this feature?

Suggest WONTFIX

Bryan.TongMinh wrote:

(In reply to comment #10)

Supposedly it would help with
https://bugzilla.wikimedia.org/show_bug.cgi?id=15159

You don't have a same origin policy in PHP.

(In reply to comment #11)

(In reply to comment #10)

Supposedly it would help with
https://bugzilla.wikimedia.org/show_bug.cgi?id=15159

You don't have a same origin policy in PHP.

No, but you still need to map interwiki prefixes to api.php URLs.

Allowing MediaWiki to access the api of something from an interwiki prefix is a different bug. This bug is about letting non-mediawiki things use the local API to access the API of another wiki through interwiki.

(In reply to comment #13)

Allowing MediaWiki to access the api of something from an interwiki prefix is a
different bug. This bug is about letting non-mediawiki things use the local API
to access the API of another wiki through interwiki.

Yeah, maybe we should split this bug into:

  • creating a table that maps fr: -> http://fr.wikipedia.org/w/api.php and making that table retrievable through the API
  • allowing proxying through the API using the aforementioned feature

mike.lifeguard+bugs wrote:

see bug 15469 too - a possible duplicate?

(In reply to comment #15)

see bug 15469 too - a possible duplicate?

I marked that one as a dupe yesterday or the day before.

  • Bug 2463 has been marked as a duplicate of this bug. ***

Bryan.TongMinh wrote:

(In reply to comment #14)

(In reply to comment #13)

Allowing MediaWiki to access the api of something from an interwiki prefix is a
different bug. This bug is about letting non-mediawiki things use the local API
to access the API of another wiki through interwiki.

Yeah, maybe we should split this bug into:

making that table retrievable through the API

  • allowing proxying through the API using the aforementioned feature

This bug clearly concentrates on the second point. I still see no reason for this feature, so I'm closing this as WONTFIX.

Is there an open bug for the other point?