Decide on moving field cardinality to the FieldDefinitionInterface

Created on 8 April 2014, almost 11 years ago
Updated 14 March 2025, 21 days ago

Follow-up from #2226197: Introduce FieldStorageDefinitionInterface in the Entity Field API β†’ .

Problem

As discussed there at comment #30 and the following comments configurable field storage right now respects the field cardinality settings *during* the load()/save() operations. As I'd have expected that to influence validation only, this was quite a WTF to me.

Moreover this might result in data loss if:
- a field has e.g. 5 possible values and a node has 5 values
- the admin changes the field so that only 3 values are allowed.
- Now only the first 3 values are loaded and viewed, but the data remains.
- Now, a user edits the node and re-saves it - possibly even without even knowing/seeing our field with 3/5 values due to field access
- The node ends up being saved with only 3 values, the remaining two values are lost now

Proposal:

Respect field cardinality only during validation. Entity storage should store/load whatever is in the storage/entity.
Move the field cardinality setting to FieldDefinitionInterface as it does not influence storage at all - for the storage it's only important to know whether a field is multiple or not what would remain on StorageFieldDefinitionInterface (or whatever it ends up being called).

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

field system

Created by

πŸ‡¦πŸ‡ΉAustria fago Vienna

Live updates comments and jobs are added and updated live.
  • API change

    Changes an existing API or subsystem. Not backportable to earlier major versions, unless absolutely required to fix a critical bug.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024