defaultStorageSettings() and defaultFieldSettings() should document that they must not have setting names in common

Created on 16 May 2024, 6 months ago

Problem/Motivation

These two methods in FieldItemInterface look like they're totally separate, but other parts of core assume that the setting names are distinct.

For example in BaseFieldDefinition the two arrays are merged:

    $default_settings = $field_type_manager->getDefaultStorageSettings($type) + $field_type_manager->getDefaultFieldSettings($type);

Steps to reproduce

Proposed resolution

Document in both methods that setting names must be different from the ones returned by the other method.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Documentation 

Last updated about 12 hours ago

No maintainer
Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @joachim
  • Status changed to Needs work 6 months ago
  • 🇵🇰Pakistan isalmanhaider

    Explanation:

    In Drupal 11, the FieldItemInterface includes two methods: defaultFieldSettings() and defaultStorageSettings(). These methods define default settings for field items at different levels:

    - defaultFieldSettings(): Specifies default settings at the field level.
    - defaultStorageSettings(): Specifies default settings at the storage level.

    Issue:

    The methods are expected to return settings with unique names. This is crucial because other parts of the core, like BaseFieldDefinition, merge these arrays. Overlapping names can lead to conflicts or unexpected behavior.

    Solution:

    Document in both methods that setting names must be distinct to avoid such issues.

  • 🇨🇦Canada karimb

    We are going to take this issue as part of the Symetris contribution workshop.

  • 🇳🇿New Zealand quietone

    Fixes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

  • 🇪🇸Spain rodrigoaguilera Barcelona

    I guess this issue never made it into the workshop. We can work on it in Barcelona.

    This issue require to write some docs into the comments of the code.

  • First commit to issue fork.
  • Pipeline finished with Success
    about 2 months ago
    Total: 1397s
    #294237
  • 🇵🇰Pakistan sadamafridi

    Updated docblock in defaultStorageSettings() method to specify the need for unique setting names.
    Updated docblock in defaultFieldSettings() method with similar instructions.

  • 🇮🇳India santhosh@21

    I have reviewed the documentation for the both methods and those are different from the ones returned by the other method and now it totally makes distinct and can avoid conflicts.

  • 🇬🇧United Kingdom joachim

    - * A list of default settings, keyed by the setting name.
    + * A list of default settings, keyed by the setting name. Each setting name
    + * must be unique to avoid conflicts when these arrays are merged by other
    + * components in the core, such as BaseFieldDefinition.

    This doesn't describe the problem.

    They are obviously unique, since they are array keys!

    We need to say unique with the OTHER method.

    There's no point mentioning BaseFieldDefinition explicitly.

  • 🇬🇧United Kingdom joachim

    Something like this in the main body of the method docs:

    > Setting names defined by this method must not duplicate the setting names returned by this plugin's implementation of OTHER METHOD, as both lists of settings are merged.

Production build 0.71.5 2024