lucaswerkmeister / wb2rdf

converts Wikibase JSON to RDF
https://tools.wmflabs.org/wb2rdf/
GNU Affero General Public License v3.0
2 stars 0 forks source link

exception thrown on phpunit test Q4 #1

Open ericprud opened 5 years ago

ericprud commented 5 years ago

inputs

result:

Notice: Undefined index: id in /data/project/wb2rdf/wb2rdf/index.php on line 235

Fatal error: Uncaught InvalidArgumentException: $serialization must be a string in /data/project/wb2rdf/wb2rdf/vendor/wikibase/data-model/src/Entity/EntityId.php:51
Stack trace:
#0 /data/project/wb2rdf/wb2rdf/vendor/wikibase/data-model/src/Entity/EntityId.php(89): Wikibase\DataModel\Entity\EntityId::assertValidSerialization(NULL)
#1 /data/project/wb2rdf/wb2rdf/vendor/wikibase/data-model/src/Entity/DispatchingEntityIdParser.php(45): Wikibase\DataModel\Entity\EntityId::splitSerialization(NULL)
#2 /data/project/wb2rdf/wb2rdf/index.php(235): Wikibase\DataModel\Entity\DispatchingEntityIdParser->parse(NULL)
#3 /data/project/wb2rdf/wb2rdf/vendor/data-values/serialization/src/Deserializers/DataValueDeserializer.php(122): {closure}(Array)
#4 /data/project/wb2rdf/wb2rdf/vendor/data-values/serialization/src/Deserializers/DataValueDeserializer.php(91): DataValues\Deserializers\DataValueDeserializer->getDeserialization(Array)
#5 /data/project/wb2rdf/wb2rdf/vendor/wikibase/data-model-serialization/src/Deserializers/SnakDeserializer.php in /data/project/wb2rdf/wb2rdf/vendor/wikibase/data-model/src/Entity/DispatchingEntityIdParser.php on line 49

Also Q6.json, Q7.json, Q9.json and Q10.json

lucaswerkmeister commented 5 years ago

The entity ID values in that JSON are missing the full entity ID:

"value": {
    "entity-type": "item",
    "numeric-id": 42
},

Entity ID values you get from Special:EntityData, on the other hand, will always contain it:

"value": {
    "entity-type": "item",
    "numeric-id": 42,
    "id": "Q42"
},

In general, I think we’re trying to move away from numeric IDs to full IDs, because numeric IDs can’t support federated entities; however, you can currently still edit Wikidata via the API with numeric IDs, so I suppose we should support them here too.

ericprud commented 5 years ago

Is the preferred format "id": "foreign:Q200" as seen in the bottom of Q4?