Problem/Motivation

At admin/structure/comment/types/add we allow sitebuilders to create comment types, and offer "Target entity type" of any content entity type. However, comment fields cannot be added to content entity types that have string primary keys (see #2205215: {comment} and {comment_entity_statistics} only support integer entity ids and #2496699: Allow comments to be attached to entities using a string primary key).

Thus sitebuilders are allowed to create comment types that they cannot actually use, without warning or explanation.

Proposed solution

At #11 @larowlan proposed a patch which removed ineligible content entity types from those offered as "Target entity type" and displayed below there the names of ineligible entity types.

Tasks

- decide whether it is necessary to display the names of the ineligible entity types
- amend patch to remove this if it is deemed unecessary
- fix failing tests

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bill richardson’s picture

Is the problem that the option has been moved from the edit page to manage fields page ?

attiks’s picture

The problem is that I can create a comment type for my custom entity (using string as id) at admin/structure/comment, but when I go to admin/structure/external-entity-types/manage/users/fields/add-field I don't see the field.

Off topic: the real fix is to solve #2496699: Allow comments to be attached to entities using a string primary key

dawehner’s picture

Is that really critical?

I think having an issue summary with more information would be helpful :)

attiks’s picture

dawehner’s picture

Interesting, this for sure sounds like a real bug we should fix :)

dawehner’s picture

Tag work

andypost’s picture

We should disable creation of comment type for non-integer IDs for 8.0.x because of beta stage.
Also comment_form_field_ui_field_storage_add_form_alter() and new alter function should point to #2496699: Allow comments to be attached to entities using a string primary key

andypost’s picture

Also it would be great to update comment_help() to dynamically generate a list of entity types that can't be commented atm

larowlan’s picture

Agree - the fix here is to prevent listing those entity types in the target-entity type field of the comment-type form.
If any do exist, we should add a description indicating why those aren't listed.

andypost’s picture

larowlan’s picture

Added message and limited available entity-types.

Failing test.

Screenshot:

The last submitted patch, 11: comment-string-type-field-2496913.fail_.patch, failed testing.

larowlan’s picture

Issue tags: +Needs usability review
Bojhan’s picture

Issue tags: -Needs usability review

This interface looks pretty afwul, can we have a update on the issue summary why we need this what usecase its meant to solve etc?

attiks’s picture

Title: UX problem with comment types » DX problem with comment types
Issue tags: -ux +DX
Bojhan’s picture

Why is this DX? This is UI? I am not sure why we ever made this decision on hiding?

I agree with #3 here, the issue summary is incomplete.

andypost’s picture

Title: DX problem with comment types » UX problem with comment types
Issue tags: -DX +Usability, +Needs issue summary update

This is UX problem - we can't add comment fields to entity type that has non-integer ID (internal)
So we need to show some message to user why he's failed to add commenting

attiks’s picture

#14 Sorry for the confusing title change, I somehow missed the screenshot of #11, but I have to agree that it looks confusing with the long list of entity types.

#17 Can you update the issue summary?

jonathanshaw’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

larowlan’s picture

Version: 8.3.x-dev » 8.4.x-dev

I think the existing patch is still the best approach - @andypost - can you review?

yoroy’s picture

I'm late to this particular party. Initial thought on first read of the issue summary was "why would we want to list the entities you can *not* add comments to?". It mostly lists stuff you likely don't want to add comments to anyway. Of course there will be exotic use cases where it would be needed. But that is not fixed by actually spelling out that you can’t anyway. I don't think we should explain up front why a certain technical limitation is reducing available options.

Not sure we need to call it out at all. If people feel strongly about somehow explaining this somewhere:

- Consider mentioning this in /admin/help/comment
- Have a "Missing some options here?" link to an explanation somewhere else (either the above help page or d.o)

But even as I type out these options I'm not sure it's helpful explaining this on the UI level *if there's nothing you can do to work around it*.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

jungle’s picture

Status: Needs review » Needs work

- Consider mentioning this in /admin/help/comment
- Have a "Missing some options here?" link to an explanation somewhere else (either the above help page or d.o)

+1 to #26, the current patch lists the unsupported entity types without an explanation which is confusing and against what this CR claimed: Comments allowed on any entity type.

However, telling site builders/drupal users the truth directly on the add comment field page, that comments does not work on string ID-based entity types, which sounds like Drupal sucks. Further more, some of them won't encounter it.

jonathanshaw’s picture

I think we'd all agree that what's most important here is hiding the entity types that don't work in the drop-down. Currently this is labelled a major bug.

What we should do explain this to users could be a lower priority follow-up task.

Let's simplify #11 to the actual uncontroversial bug fix and get it in first.

jungle’s picture

Let's simplify #11 to the actual uncontroversial bug fix and get it in first.

Well, made a patch based on #11, tagging Bug Smash Initiative

jungle’s picture

+++ b/core/modules/comment/src/CommentTypeForm.php
@@ -100,10 +101,10 @@ public function form(array $form, FormStateInterface $form_state) {
-        // Only expose entities that have field UI enabled, only those can
-        // get comment fields added in the UI.

Self-review: should not remove the comment.

The last submitted patch, 36: 2496913-36-test-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 36: 2496913-36.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review
FileSize
3.42 KB
1.65 KB

Fixing the test cases.
I think in test cases we were asserting incorrect checks.
We should check "responseNotContains()". The reason is, we are expecting that entities with integer id should appear in the list.
Test is passing on local now.

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

Seems right to me.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 40: 2496913-40.patch, failed testing. View results

jonathanshaw’s picture

Title: UX problem with comment types » Don't expose entity types with string ids as a target option when creating comment types
benjifisher’s picture

Please do not ask the testbot to try again until #3207086: [HEAD BROKEN] Consistent failure in MonthDatePluginTest is fixed.

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

  • catch committed 5cce18a on 9.2.x
    Issue #2496913 by larowlan, jungle, mohit_aghera, attiks, andypost,...

  • catch committed ef6de99 on 9.1.x
    Issue #2496913 by larowlan, jungle, mohit_aghera, attiks, andypost,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Good to see this RTBC after so long. If we ever make comments work with string ID entity types we can reverse it of course.

Committed/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.