Problem/Motivation

On field storage the form can be submitted even the "Comment type" dropdown shows no entries. This creates a comment field with an empty comment_type.

Steps to reproduce

  1. Go to: Admin > Structure > Taxonomy
  2. Create a new vocabulary
  3. On the new vocabulary page click the "Manage fields" tab, then click "Add field"
  4. Select "Comment" from "Add a new field" dropdown, fill a field name and press "Save and continue"
  5. Note that the "Comment type" select is empty.

You cannot submit this form because the field has no value but if you go back to the "Manage fields" page (may requirrefresh), you'll note tha the field has been added.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

claudiu.cristea created an issue. See original summary.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
larowlan’s picture

I think this is because \Drupal\comment\Plugin\Field\FieldType\CommentItem::defaultStorageSettings defaults to an empty string

Perhaps we should try to find a valid comment type instead?

joachim’s picture

> Perhaps we should try to find a valid comment type instead?

There will typically be no valid comment type, as the user is unlikely to know that they need to create the comment type first.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lauriii’s picture

The creation of invalid field storage config entity is possible because of #2327883: Field [storage] config have incomplete settings until they are saved and #3324140: Convert field_storage_config and field_config's form validation logic to validation constraints. We will probably address part of this in #3358049: Save FieldStorageConfig at the same time as FieldConfig because you wouldn't be able to pass the second step. However, we could potentially further improve the UX by adding validation to the first step that would only allow adding the field if there are valid comment types.

wim leers’s picture

Thanks for surfacing this one, @lauriii!

wim leers’s picture

Title: Creating comment field w/o a comment type is allowed » [PP-1] Creating comment field w/o a comment type is allowed
Status: Active » Postponed
Related issues: +#3324140: Convert field_storage_config and field_config's form validation logic to validation constraints

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

herved’s picture

I discovered an issue in CommentLinksTest.php revealed by #2879087-148: Use comment access handler instead of hardcoding permissions
There are other cases in tests where the comment type is not created.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.