Page MenuHomePhabricator

Wikidata forms without statements use empty JSON array instead of empty JSON object
Closed, ResolvedPublic

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: [].

Notes:

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

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 subscribed.

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

Change 676820 had a related patch set uploaded (by Lucas Werkmeister; author: Lucas Werkmeister):

[mediawiki/extensions/Wikibase@master] Tag JSON type of subentity statements

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

Change 676822 had a related patch set uploaded (by Lucas Werkmeister; author: Lucas Werkmeister):

[mediawiki/extensions/WikibaseLexeme@master] Add unit test to verify empty lists' metadata

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

Change 677353 had a related patch set uploaded (by Lucas Werkmeister; author: Lucas Werkmeister):

[mediawiki/extensions/WikibaseLexeme@master] Temporarily skip a ResultBuilderLexemeTest

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

Sounds like this patch's time has finally come https://gerrit.wikimedia.org/r/c/wikibase/termbox/+/555937 It's mostly related to T138104 but since that has been resolved I'm posting it here.
Pinging @Addshore as the one who abandoned the patch and @Jakob_WMDE as the one who introduced (I think? https://gerrit.wikimedia.org/r/c/wikibase/termbox/+/502826 ) the functionality being removed in that patch.

@Tonina_Zhelyazkova_WMDE Nice! Yes, it looks like that ugly bit of code can be deleted now!

Moving this back to Doing so I can introduce the temporary setting wrapping Lucas's change and also see about that termbox patch.

Change 685776 had a related patch set uploaded (by Tonina Zhelyazkova; author: Tonina Zhelyazkova):

[operations/mediawiki-config@master] Add Add tmpSerializeEmptyListsAsObjects Wikibase repo config

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

Change 677353 abandoned by Lucas Werkmeister:

[mediawiki/extensions/WikibaseLexeme@master] Temporarily skip a ResultBuilderLexemeTest

Reason:

no longer needed, since the Wikibase change is now behind a feature flag

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

Change 688184 had a related patch set uploaded (by Tonina Zhelyazkova; author: Tonina Zhelyazkova):

[operations/mediawiki-config@master] Add tmpSerializeEmptyListsAsObjects to Wikibase.php

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

Change 569228 abandoned by Hoo man:

[mediawiki/extensions/WikibaseLexeme@master] Add unit test to verify empty lists' metadata

Reason:

Duplicate of https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikibaseLexeme/ /676822

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

Change 676820 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Tag JSON type of subentity statements

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

Change 676822 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Add unit test to verify empty lists' metadata

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

Change 685776 merged by jenkins-bot:

[operations/mediawiki-config@master] Add tmpSerializeEmptyListsAsObjects Wikibase repo config

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

Change 688184 merged by jenkins-bot:

[operations/mediawiki-config@master] Add tmpSerializeEmptyListsAsObjects to Wikibase.php

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

Mentioned in SAL (#wikimedia-operations) [2021-05-10T11:19:05Z] <urbanecm@deploy1002> Synchronized wmf-config/InitialiseSettings.php: 6138c64e7c13fbc52ad084c0901bdd2ab30ad953: Add tmpSerializeEmptyListsAsObjects Wikibase repo config (T241422) (duration: 00m 57s)

Mentioned in SAL (#wikimedia-operations) [2021-05-10T11:20:33Z] <urbanecm@deploy1002> Synchronized wmf-config/Wikibase.php: 7f6f8497cdfba6d766e3e6974ee15a492f0518ac: Add tmpSerializeEmptyListsAsObjects to Wikibase.php (T241422) (duration: 01m 01s)

This can't be tested currently as it's behind a feature flag which we haven't enabled yet.
An announcement should be crafted first. Moving to Stalled while we figure out the plan with ComCom.

Change 694339 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):

[operations/mediawiki-config@master] Test Wikidata: Enable empty list to object serialization

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

Change 694339 merged by jenkins-bot:

[operations/mediawiki-config@master] Test Wikidata: Enable empty list to object serialization

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

Mentioned in SAL (#wikimedia-operations) [2021-05-26T11:05:44Z] <lucaswerkmeister-wmde@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Config: [[gerrit:694339|Test Wikidata: Enable empty list to object serialization (T241422)]] (duration: 01m 19s)

The deployment on test Wikidata was announced on 2021-05-27, so we can have the next step on the 10th of June at the earliest.

Addshore added a subscriber: ItamarWMDE.

It is after the 10th June, so moving back to TODO
Removing @ItamarWMDE as he is no longer on camp

This week is only emergency deployment only according to the deployment calendar (allhands). Should we deploy it?

I think this can wait for another week, since we didn’t announce a specific date anyway.

Change 700491 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[operations/mediawiki-config@master] Set $wmgWikibaseTmpSerializeEmptyListsAsObjects to true everywhere

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

Change 700491 merged by jenkins-bot:

[operations/mediawiki-config@master] Set $wmgWikibaseTmpSerializeEmptyListsAsObjects to true everywhere

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

Mentioned in SAL (#wikimedia-operations) [2021-06-21T09:44:27Z] <ladsgroup@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Config: [[gerrit:700491|Set $wmgWikibaseTmpSerializeEmptyListsAsObjects to true everywhere (T241422)]] (duration: 00m 57s)

Addshore claimed this task.

LGTM in prod

image.png (347×504 px, 15 KB)

Mentioned in SAL (#wikimedia-cloud) [2021-06-28T17:54:44Z] <wm-bot> <lucaswerkmeister> deployed 64c5584c9d (remove workaround for T241422)