Page MenuHomePhabricator

MediaInfo JSON and Lua data missing datatype information in snaks
Closed, DuplicatePublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

What happens?:
The data contains main snaks like this (JSON syntax):

{
  "snaktype": "value",
  "property": "P180",
  "hash": "a15d400991061ac3ac583f46991b86f59d7d00af",
  "datavalue": {
    "value": {
      "entity-type": "item",
      "numeric-id": 1426529,
      "id": "Q1426529"
    },
    "type": "wikibase-entityid"
  }
}

And qualifiers like this:

{
  "snaktype": "value",
  "property": "P2677",
  "hash": "0c65532bc8f079d2ad4cbab733200a75ba42e31e",
  "datavalue": {
    "value": "pct:0,34.2817,18.9812,65.3627",
    "type": "string"
  }
}

What should have happened instead?:
The snaks should include the datatype of the property to which the snaks belong, like you would find on Wikidata:

{
  "snaktype": "value",
  "property": "P106",
  "hash": "7992d2aec094f84d664106049d9a4955d096082f",
  "datavalue": {
    "value": {
      "entity-type": "item",
      "numeric-id": 6625963,
      "id": "Q6625963"
    },
    "type": "wikibase-entityid"
  },
  "datatype": "wikibase-item"
}
{
  "snaktype": "value",
  "property": "P580",
  "hash": "68d492daaeed01d65e875ac221c09b26399b8ba6",
  "datavalue": {
    "value": {
      "time": "+1979-00-00T00:00:00Z",
      "timezone": 0,
      "before": 0,
      "after": 0,
      "precision": 9,
      "calendarmodel": "http://www.wikidata.org/entity/Q1985727"
      },
    "type": "time"
    },
  "datatype": "time"
}

I suspect this is due to T149410: For consistency MediaInfo serialization should use "claims" as key, rather than "statements": Wikibase probably goes through the serialization and adds the datatype below claims, but not below statements.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:

Event Timeline

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

I suspect this is due to T149410: For consistency MediaInfo serialization should use "claims" as key, rather than "statements": Wikibase probably goes through the serialization and adds the datatype below claims, but not below statements.

Yup.

JsonDataTypeInjector::injectEntitySerializationWithDataTypes()
return $this->modifier->modifyUsingCallbacks(
    $serialization,
    [
        'claims/*/*/mainsnak' => $callback,
        '*/*/claims/*/*/mainsnak' => $callback, // statements on subentities                                                                                                                                                                                                                  
        'claims/*/*/qualifiers' => $groupedCallback,
        'claims/*/*/references/*/snaks' => $groupedCallback,
        '*/*/claims/*/*/qualifiers' => $groupedCallback,
        '*/*/claims/*/*/references/*/snaks' => $groupedCallback,
    ]
);

No statements in sight.