Page MenuHomePhabricator

Wikidata forms without statements use empty JSON array instead of empty JSON object
Open, MediumPublic

Description

Following T138104 empty "containers" in the JSON representation of entity data (e.g. returned by wbgetentities API) should be empty JSON objects, not empty JSON array (i.e. {} not []}.

It seems statements in forms be still represented as empty JSON arrays in place of empty JSON objects.

For instance, https://www.wikidata.org/w/api.php?action=wbgetentities&format=json&ids=L3872 returns "claims":[] in the serialization of L3872-F2.

{
  "entities": {
    "L3872": {

(...)

      "claims": {},
      "forms": [
        {
          "id": "L3872-F1",

(...)

          "claims": []
        },
        {
          "id": "L3872-F2",

(...)

          "claims": []
        }
      ],
      "senses": [

(...)

      ]
    }
  },
  "success": 1
}

Expected state (acceptance criterion): if the lexeme form or sense has not statements stored, the JSON representation of its data should contain claims: {} entry, not claims: [].

Details

Related Gerrit Patches:
mediawiki/extensions/WikibaseLexeme : masterAdd unit test to verify empty lists' metadata
mediawiki/extensions/Wikibase : masterFix testEmptyLists
mediawiki/extensions/Wikibase : masterAdd unit test to verify empty lists' metadata

Event Timeline

Pintoch created this task.Dec 24 2019, 4:31 PM
Pintoch updated the task description. (Show Details)
Addshore added a subscriber: Addshore.

We should pick this up before the next release on mediawiki & thus wikibase so we release some sort of consistent presentation

Addshore triaged this task as Medium priority.Jan 14 2020, 1:15 PM
WMDE-leszek updated the task description. (Show Details)Jan 28 2020, 11:21 AM
WMDE-leszek updated the task description. (Show Details)

Change 569228 had a related patch set uploaded (by Silvan Heintze; owner: Silvan Heintze):
[mediawiki/extensions/WikibaseLexeme@master] Add unit test to verify empty lists' metadata

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

Change 569229 had a related patch set uploaded (by Silvan Heintze; owner: Silvan Heintze):
[mediawiki/extensions/Wikibase@master] Add unit test to verify empty lists' metadata

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

The two related patch sets do not fix the issue described in this task, they only add unit tests to cover the required changes. Fixing the issue will include enhancing WikibaseLexeme's forms and senses with metadata that are currently hard-wired into Wikibase's ResultBuilder. This looks complex and is probably out-of-scope for the task described here.

Change 569229 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add unit test to verify empty lists' metadata

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

Change 572397 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/Wikibase@master] Fix testEmptyLists

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

DannyS712 added a subscriber: DannyS712.

The tests had an issue. From https://integration.wikimedia.org/ci/job/wmf-quibble-core-vendor-mysql-php72-docker/15551/console

19:30:45 The data provider specified for Wikibase\Repo\Tests\Api\ResultBuilderTest::testEmptyLists is invalid.
19:30:45 PHPUnit\Util\Exception: Method provideTestEmptyLists does not exist
19:30:45 /workspace/src/tests/phpunit/suites/ExtensionsTestSuite.php:31
19:30:45 /workspace/src/tests/phpunit/suites/ExtensionsTestSuite.php:43
19:30:45 /workspace/src/maintenance/doMaintenance.php:99

Change 572397 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Fix testEmptyLists

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