[Task] Create extension mechanism for Wikibase Repository
Closed, ResolvedPublic

Description

In order to support new entity types in Wikibase Repository, extensions need to be able to register handlers for the entity types they add. There are dozens of types of such handlers that need to be registrable. (Not just for new entity types.)

At present most handler lists are set in the top level factory (WikibaseRepo), or are being refactored towards being set there.

Example: getEntityIdParser in WikibaseRepo provides an EntityIdParser to the rest of the code, avoiding the using code to bind to any specific parsers or global state. This method that constructs it can add support for new types of entity ids, though it needs to somehow get the information from the extensions.

JeroenDeDauw updated the task description. (Show Details)
JeroenDeDauw raised the priority of this task from to High.
JeroenDeDauw changed Security from none to None.
JeroenDeDauw added subscribers: Unknown Object (MLST), thiemowmde, hoo and 6 others.

We could just bolt the whole pile of extension points on top of the WikibaseRepo class. Then extensions to Wikibase Repository could do something like

$wikibaseRepo->registerEntityIdParser( $myNewEntityIdParser );

This will add a lot of state to WikibaseRepo, which already has quite some state (though all state with a different purpose). Adding a distinct service that is then used by WikibaseRepo is probably better. Looking into this more before actually making changes is advised, since changing it later will be difficult.

Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
JanZerebecki renamed this task from Create extension mechanism for Wikibase Repository to Create extension mechanism for Wikibase Repository for new entity types.Feb 27 2015, 11:08 AM
JeroenDeDauw renamed this task from Create extension mechanism for Wikibase Repository for new entity types to Create extension mechanism for Wikibase Repository.Feb 27 2015, 1:12 PM
JeroenDeDauw updated the task description. (Show Details)
daniel added a comment.Feb 4 2016, 2:57 PM

One way to go about this is to add factory methods for all the relevant services to the EntityHandler sublcass for the respective entity type. Since MediaWiki already has a registry for ContentHandlers, and each entity type is bound to a content model, this should work fine. All that is needed at the root is a list of all relevant content models, this already exists, and can be modified via the WikibaseContentModelMapping hook.

However, any entity type specific code needed on the client cannot use this mechanism, since the EntityHandler is not (and should not be) present on the client. This is true in particular for the serializer and unserializer.

Bene renamed this task from Create extension mechanism for Wikibase Repository to [Task] Create extension mechanism for Wikibase Repository.Feb 5 2016, 1:10 PM
Bene added a subscriber: Bene.

Change 268667 had a related patch set uploaded (by Bene):
Use $wgContentHandlers to register custom handlers

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

Bene claimed this task.Feb 5 2016, 1:44 PM
Bene edited projects, added Wikidata-Sprint-2016-02-02; removed Patch-For-Review.
Bene added a project: Patch-For-Review.
Bene removed a subscriber: gerritbot.

@daniel: this task is not just about entity types. As for forcing such extensions to bind to content handler... this really does not seem nice dependency wise.

Change 268667 merged by jenkins-bot:
Use $wgContentHandlers to register custom handlers

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

Change 270643 had a related patch set uploaded (by Bene):
[DNM] Draft entity type registry

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

Bene moved this task from Doing to Done on the Wikidata-Sprint-2016-02-16 board.Feb 21 2016, 11:35 PM
Bene moved this task from Done to Review on the Wikidata-Sprint-2016-02-16 board.

Change 270643 merged by jenkins-bot:
Create entity type registry

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

Change 271140 had a related patch set uploaded (by Bene):
Use EntityTypeDefinitions in repo and client

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

Change 271140 merged by jenkins-bot:
Use EntityTypeDefinitions in repo and client

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

Bene moved this task from Doing to Done on the Wikidata-Sprint-2016-03-01 board.Mar 3 2016, 12:58 PM
Bene closed this task as Resolved.