Page MenuHomePhabricator

Replace EntityFactory::newEmpty() with ChangeOpDeserializer::createEntity( $changeRequest )
Closed, ResolvedPublic


Some kinds of entities (e.g. Lexemes) cannot be "empty" - in other words, they have required constructor parameters.

In order to construct such entities from the data provided by a client (e.g. in a call to wbeditentity), we need code that can construct an Entity of a given type based on constructor parameters encoded in a JSON structure.

This is conceptually very similar to what ChangeOpDeserializer already does for modifications of entities (by constructing the respective ChangeOps from the a JSON structure provided by the client in an API call). The same should now be done for constructing an entity.

Note: constructor arguments will need to have the same validation applied that would be applied by ChangeOps for the respective fields. The ChangeOpDeserializer should already have access to any services required for this, since it is a factory for the ChangeOps that would perform the check.

Note: EntitySavingHelper will need to be changed quite a bit so it can use ChangeOpDeserializer::createEntity() instead of EntityFactory::newEmpty(). Once this is done, the EntityFactory class can be removed.

Note: Most API modules that use EntitySavingHelper do not get sufficient information from the client to construct a non-empty entity. Automatic create-on-edit for "virtual" entities only works for entity types that do not have any required fields (other than the ID).

See for rationale and discussion

Event Timeline

daniel created this task.May 31 2017, 3:42 PM
Lydia_Pintscher triaged this task as Low priority.Jun 11 2017, 5:02 PM
Lydia_Pintscher moved this task from incoming to ready to go on the Wikidata board.

@Lydia_Pintscher this is needed to allow creation of Lexemes via the API. It's a blocker, not just "nice to have".

Restricted Application added a subscriber: PokestarFan. · View Herald TranscriptJul 24 2017, 4:12 PM
Lydia_Pintscher closed this task as Resolved.May 23 2018, 2:22 PM
Lydia_Pintscher claimed this task.

FWIW: This has not really been achieved as described in the task.