Problem/Motivation
Followup from #2333113-72: Add an EntityDefinitionUpdateManager so that entity handlers can respond (e.g., by updating db schema) to code updates in a controlled way (e.g., from update.php). In that issue, EntityDefinitionUpdateManager has the following code:
$entity_type = $this->entityManager->getDefinition($entity_type_id);
$original = $this->entityManager->getLastInstalledDefinition($entity_type_id);
$this->entityManager->onEntityTypeUpdate($entity_type, $original);
And similar code to do the same for a field storage definition. Additionally, there's similar code in field_test_entity_info_translatable(), which also needs to do a definition update, and can safely do it in-process, rather than via EntityDefinitionUpdateManager, since it's a helper function for a test, where it knows there aren't entities saved yet for the entity type being changed.
It seems silly to require 3 function calls on the entity manager to do this.
Proposed resolution
Option 1: Add a method to EntityManager to do those 3 steps?
Option 2: Add extra methods or parameters to EntityDefinitionUpdateManager instead, to keep that the consistent entry point for updates?
Comments
Comment #1
plachComment #8
amateescu commentedWe added
EntityDefinitionUpdateManagerInterface::(install|update|uninstall)EntityType()and similar for storage definitions in #2542748: Automatic entity updates can fail when there is existing content, leaving the site's schema in an unpredictable state, so I think we can close this.