Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 300130

Entity updates don't work for adding a bundle to an existing entity type

$
0
0

Problem/Motivation

The use case is very simple: you have an entity type which is not yet bundleable but was installed. In a subsequent effort, a bundle key and base field is added and the updates are run. However, the check for determining if there are changes between the installed version and the new definition fails due to wrong data used for doing this.

The main culprit is SqlContentEntityStorageSchema::requiresEntityStorageSchemaChanges which calls getEntitySchema() on the new entity type definition. The problem is that the SqlContentEntityStorageSchema, when instantiated, uses the active (installed) field storage definitions and getEntitySchema() throws an exception due to a missing field which is expected due to the table mapping using the new entity definition to determine the list of fields. So essentially we are comparing the new entity definition but using installed field storage definitions.

See SqlContentEntityStorageSchema:978 for the exception and SqlContentEntityStorageSchema:955 for where the table mapping is created using the new entity type definition together with the installed field storage definitions.

Proposed resolution

I would imagine is to do like elsewhere and when calling getEntitySchema() for this purpose, to use the correct, i.e. fresh field definitions.

Remaining tasks

Work the patch.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet


Viewing all articles
Browse latest Browse all 300130

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>