Page MenuHomePhabricator

WikibaseMediaInfo serializes empty statements as empty array [] instead of empty object {} in JSON
Open, LowPublic

Description

I noticed this while testing T138104: Do not serialize empty containers (descriptions/aliases/sitelinks) as empty array [] on Commons – for example, https://commons.wikimedia.org/wiki/Special:EntityData/M52609519.json now looks like this:

{
  "entities": {
    "M52609519": {
      "pageid": 52609519,
      "ns": 6,
      "title": "File:Wikidata time-latitude visualization - 2016-10-24.png",
      "lastrevid": 334910923,
      "modified": "2019-01-15T10:44:57Z",
      "type": "mediainfo",
      "id": "M52609519",
      "labels": {
        "en": {
          "language": "en",
          "value": "The x-axis (left/right) represents time, the y-axis (top/down) represents space / geolocation."
        },
        "fr": {
          "language": "fr",
          "value": "Visualisation de Wikidata"
        }
      },
      "descriptions": {},
      "statements": []
    }
  }
}

The statements (why aren’t they called claims as in Wikidata, by the way? T149410) should be an empty object, not an empty array. Compare with https://commons.wikimedia.org/wiki/Special:EntityData/M77486990.json:

{
  "entities": {
    "M77486990": {
      "pageid": 77486990,
      "ns": 6,
      "title": "File:Andrejeva von Skilondz, opera singer - SMV - NS052.tif",
      "lastrevid": 347257955,
      "modified": "2019-04-25T19:53:39Z",
      "type": "mediainfo",
      "id": "M77486990",
      "labels": {},
      "descriptions": {},
      "statements": {
        "P180": [
          {
            "mainsnak": {
              "snaktype": "value",
              "property": "P180",
              "datavalue": {
                "value": {
                  "entity-type": "item",
                  "numeric-id": 4681829,
                  "id": "Q4681829"
                },
                "type": "wikibase-entityid"
              }
            },
            "type": "statement",
            "id": "M77486990$acff4b81-447c-f94b-ec62-5c0162841d22",
            "rank": "normal"
          }
        ]
      }
    }
  }
}

Event Timeline

Addshore subscribed.

Would be great to get this fixed by the StructuredDataOnCommons team, should be pretty trivial!

Mentioned in SAL (#wikimedia-cloud) [2019-11-01T11:16:17Z] <wm-bot> <lucaswerkmeister> deployed 520c618b5a (work around T222159); temporary experiment still in effect

Mentioned in SAL (#wikimedia-cloud) [2021-01-31T15:20:26Z] <wm-bot> <lucaswerkmeister> deployed 981843b704 (work around T222159)