Page MenuHomePhabricator

wbgetitems/wbgetentities: api requests fail on multiple site/title pairs
Closed, ResolvedPublic

Details

Reference
bz42060

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:01 AM
bzimport set Reference to bz42060.
bzimport added a subscriber: Unknown Object (MLST).

This request has 19 sites and 14 titles. That will reuse the shortest array to fill the remaining entries for the sites.

I'm not sure why the titles comes back empty.

I localized the actual code, and this code sequence was changed after branch 0.1 was made. I guess the old code still have a bug. The new code will cyclic reuse missing titles and sites so it is possible to write something like

http://www.wikidata.org/w/api.php?action=wbgetitems&props=info&sites=enwiki&titles=Norge|Noreg|Norway|Norwegen

This will try the pairs
enwiki - Norge
enwiki - Noreg
enwiki - Norway
enwiki - Norwegen

and then return the found entity

<?xml version="1.0"?>
<api success="1">

<entities>
  <entity site="enwiki" title="Norge" missing="" />
  <entity site="enwiki" title="Noreg" missing="" />
  <entity site="enwiki" title="Norwegen" missing="" />
  <entity pageid="127194" ns="0" title="Q5786" lastrevid="169682" modified="2012-11-26T15:47:43Z" id="q5786" type="item" />
</entities>

</api>

The original code doesn't seem to handle overflow entries very well, but the newer code does work. In the previous case it seems like misbehaving code tried to get undefined site ids and titles.

Especially note the following case
http://wikidata-test-repo.wikimedia.de/w/api.php?action=wbgetentities&props=info&sites=enwiki|nnwiki|nowiki&titles=Norway|Noreg|Norge

Which will report a single found entity of type item

<?xml version="1.0"?>
<api success="1">

<entities>
  <entity pageid="127194" ns="0" title="Q5786" lastrevid="169684" modified="2012-11-26T15:55:10Z" id="q5786" type="item" />
</entities>

</api>

As an additional note the previous will produce sitelinks in the latest version on wikidata-test-repo

http://wikidata-test-repo.wikimedia.de/w/api.php?action=wbgetentities&props=sitelinks/urls|info&sites=enwiki|nnwiki|nowiki&titles=Norway|Noreg|Norge

<?xml version="1.0"?>
<api success="1">

<entities>
  <entity pageid="127194" ns="0" title="Q5786" lastrevid="169684" modified="2012-11-26T15:55:10Z" id="q5786" type="item">
    <sitelinks>
      <sitelink site="enwiki" title="Norway" url="http://en.wikipedia.org/wiki/Norway" />
      <sitelink site="nnwiki" title="Noreg" url="http://nn.wikipedia.org/wiki/Noreg" />
      <sitelink site="nowiki" title="Norge" url="http://no.wikipedia.org/wiki/Norge" />
    </sitelinks>
  </entity>
</entities>

</api>

Change I34abd62e: Minor cleanup to wbgetentities

Verified in Wikidata demo time for sprint 24

Restricted Application added a subscriber: StudiesWorld. · View Herald Transcript