Page MenuHomePhabricator

[ES-M2]: Updating EntitySchema to make use of the new mechanism
Open, Needs TriagePublic

Description

To make use of the new mechanism implemented in the patch from the Product Platform team, we need to make some changes on the EntitySchema side.

When parsing statement/qualifier/reference values, Wikibase will take into account the corresponding Property's data type and not only the value type. A data type specific value parser can be registered with the data type definition (here: EntitySchema). This will allow serialized EntitySchema values to contain type: wikibase-entityid without being parsed as an EntityIdValue.

The changes that are required are:

  • New value type
  • New parser/deserializer
  • Adjust validators

Acceptance criteria

  • Users are able to create an EntitySchema data value type statement
  • Users are able to load an EntitySchema data value type statement and it is linked to the EntitySchema

To create a statement using the API sandbox, use the wbsetclaim action, let the API sandbox fill in the token parameter, and set the claim to JSON similar to this:

{"type":"statement","mainsnak":{"snaktype":"value","property":"P592","datavalue":{"type":"wikibase-entityid","value":{"id":"E1"}}},"id":"P592$6dcf36c9-238a-435b-8ead-6fd1915b8548","rank":"normal"}

Where P592 is a property with data type EntitySchema, 6dcf36c9-238a-435b-8ead-6fd1915b8548 is a random UUID (you can get a fresh one from cat /proc/sys/kernel/random/uuid), and E1 is the ID of an existing EntitySchema.

Event Timeline

@Lucas_Werkmeister_WMDE can you please add the info for the API sandbox?

To make use of the new mechanism implemented in the patch from the Product Platform team

I’m trying to figure out what the status of that mechanism is… the relevant tasks seem to be T354778 and T359421, and the big change adding the new mechanism (corresponding to the prototype changes in T355144) seems to be Wire up DataTypeAwareSnakDeserializer.

Change #994206 had a related patch set uploaded (by Arthur taylor; author: Jakob):

[mediawiki/extensions/EntitySchema@master] Use custom entity schema value parser

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

Change #1007655 had a related patch set uploaded (by Arthur taylor; author: Jakob):

[mediawiki/extensions/EntitySchema@master] Register entity schema data type for clients

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

Change #1023082 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/EntitySchema@master] Add formatting for EntitySchema values

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

Change #994206 merged by jenkins-bot:

[mediawiki/extensions/EntitySchema@master] Use custom entity schema value parser

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

Change #1007655 merged by jenkins-bot:

[mediawiki/extensions/EntitySchema@master] Register entity schema data type for clients

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

Change #1023082 merged by jenkins-bot:

[mediawiki/extensions/EntitySchema@master] Add formatting for EntitySchema values

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

Tried to test this on beta now with:

{"type":"statement","mainsnak":{"snaktype":"value","property":"P253077","datavalue":{"type":"wikibase-entityid","value":{"id":"E10"}}},"id":"P253077$96461d0e-06dd-11ef-9fbf-8b25ca3a3caf","rank":"normal"}

I get the message that my user doesn't have permission to make edits in the property namespace:

{
    "error": {
        "code": "failed-save",
        "info": "The save has failed.",
        "messages": [
            {
                "name": "wikibase-api-failed-save",
                "parameters": [],
                "html": "The save has failed."
            },
            {
                "name": "namespaceprotected",
                "parameters": [
                    "Property",
                    "edit"
                ],
                "html": "You do not have permission to edit pages in the <strong>Property</strong> namespace."
            },
            {
                "name": "permissionserrors",
                "parameters": [],
                "html": "Permission error"
            }
        ],
        "docref": "See https://wikidata.beta.wmflabs.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt; for notice of API deprecations and breaking changes."
    },
    "servedby": "deployment-mediawiki11"
}

@Lucas_Werkmeister_WMDE do you have permission?

[…]
I get the message that my user doesn't have permission to make edits in the property namespace:
[…]
@Lucas_Werkmeister_WMDE do you have permission?

You can just try the edit on an item, by changing the claim's "id", eg. to Q584208$6dcf36c9-238a-435b-8ead-6fd1915b8548 to edit item Q584208. Also I made you an administrator on beta Wikidata now… while not needed here, it could come in handy sometime.

I submitted an edit with the same statement (on a different entity) and got:

{
	"error": {
		"code": "modification-failed",
		"info": "Data value corrupt: Can not parse id 'E1' to build EntityIdValue with",
		"messages": [
			{
				"name": "wikibase-validator-bad-value",
				"parameters": [
					"Can not parse id 'E1' to build EntityIdValue with"
				],
				"html": {
					"*": "Data value corrupt: Can not parse id 'E1' to build EntityIdValue with"
				}
			}
		],
		"*": "See https://wikidata.beta.wmflabs.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt; for notice of API deprecations and breaking changes."
	}
}