EntityDefinitionUpdateManager::getChangeList always marks bundle fields added in code as 'needs to be deleted'

Created on 28 September 2020, almost 4 years ago
Updated 7 November 2023, 10 months ago

Problem/Motivation

Method \Drupal\Core\Entity\EntityDefinitionUpdateManager::getChangeList always marks bundle fields added in code as 'needs to be deleted'

Steps to reproduce

Create a custom entity type, define a field with method bundleFieldDefinitions in the entity class. If you open page /admin/reports/status it says that the field you defined needs to be deleted.
TODO Try to reproduce with hook_entity_bundle_field_info and bundle of node

Proposed resolution

Not sure about the proper solution, Drupal guru may suggest smth better. I see next ways
1. \Drupal\Core\Entity\EntityFieldManager::getFieldStorageDefinitions has to include bundle fields in their result. In this case we have to review all usages of the method (there are a lot of them) to make sure it won't break other functionalities
2. Update method \Drupal\Core\Entity\EntityDefinitionUpdateManager::getChangeList so, that it gets base field storage definitions and bundle field storage definitions and only after that compares it with installed field storage definitions.

Remaining tasks

1. Choose a way to fix it
2. Create patch

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component
Field 

Last updated 1 day ago

Created by

🇷🇺Russia sergei_brill

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia acbramley

    Is this reproducible on 11.x? If so, can you please provide code snippets?

    It definitely works with node bundles, we use the alter hook extensively on client projects.

Production build 0.71.5 2024