Problem:
Calling the action=query&list=wbsubscribers API endpoint on a Wikibase returns a response with two different keys that could potentially contain results: subscribers and wbsubscribers. In addition, the XML response format is not structured as expected.
Examples:
Calling https://www.wikidata.org/w/api.php?action=query&list=wbsubscribers&wblsentities=L1-S1 results in:
{ "batchcomplete": "", "query": { "wbsubscribers": {}, "subscribers": { "L1-S1": { "subscribers": [ { "site": "wikidatawiki" } ] } } } }
<?xml version="1.0"?> <api batchcomplete=""> <query> <wbsubscribers /> <subscribers> <L1-S1> <subscribers> <subscriber site="wikidatawiki" /> </subscribers> </L1-S1> </subscribers> </query> </api>
Desired behavior:
The results are added to only one key (either subscribers OR wbsubscribers), and in the correct XML structure.
<?xml version="1.0"?> <api batchcomplete=""> <query> <subscribers> <entity id="L1-S1"> <subscribers> <subscriber site="wikidatawiki" /> </subscribers> </entity> </subscribers> </query> </api>
Notes:
This behavior is essentially caused by a typo in the code that sets up the API module. Essentially, it sets up $this->getModuleName() with wbsubscribers:
$result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'entity' ); $result->addArrayType( [ 'query', $this->getModuleName() ], 'kvp', 'id' );
But then adds values under subscribers, without the wb:
$fit = $result->addValue( [ 'query', 'subscribers' ], $row->cs_entity_id, $entry );