Allow relationships between comments in Views

Created on 17 October 2024, 6 months ago

Problem/Motivation

I have set a comment field on a comment entity. Yes, it is a comment on a comment on a User.

The problem is that I cannot use relationships in Views because there is a condition which forbids relationships between comments. There is no explanation in the code on why it's not allowed. Here is the code:

    //...

    // Provide a relationship for each entity type except comment.
    foreach ($entities_types as $type => $entity_type) {
      if ($type == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) {
        continue;
      }

      //...

Steps to reproduce

Have a comment field set on a comment. Then go to Views. What is expected is to have the relationship: "The Comment to which the comment is a reply to.", but it's not there.

Proposed resolution

Remove the restriction on the comment type, or document why it's not allowed.

    // Provide a relationship for each entity type.
    foreach ($entities_types as $type => $entity_type) {
      if (!$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) {
        continue;
      }

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.4

Component

comment.module

Created by

🇫🇷France dakwamine

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

Comments & Activities

Production build 0.71.5 2024