Comment type entity should declare dependency on extension of the target entity type

Created on 4 February 2017, over 7 years ago
Updated 11 September 2023, 9 months ago

Problem/Motivation

The comment.type.comment.yml config which is shipped with the standard profile has an undeclared dependency on its target entity type..

How to reproduce

  1. Install Drupal with the Standard profile.
  2. Head over to /admin/modules/uninstall.
  3. Uninstall the History and Taxonomy modules.
  4. Uninstall the Node module.
  5. Visit /admin/structure/comment/manage/comment/delete.

You should see PluginNotFoundException: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition()

Proposed resolution

Add dependencies from the comment field and the target entity type.

Remaining tasks

  1. Update tests
  2. Patch.

User interface changes

User is expected to see dependency information when attempting to delete.

API changes

Nil

Data model changes

Nil

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Comment 

Last updated 3 days ago

Created by

🇺🇸United States shadcn

Live updates comments and jobs are added and updated live.
  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

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.

  • 🇳🇿New Zealand DanielVeza Brisbane, AU
    +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
    @@ -192,6 +192,22 @@ public function testCommentTypeDeletion() {
    +    $this->assertSession()->pageTextNotContains('node_dependent');
    

    Should we add an assert here that the status code is a 200?

    Needs a reroll for 10.1.x and the upgrade path tests

  • 🇦🇺Australia dpi Perth, Australia

    Since this is no longer about Node, tests should also be re-worked to use the generic EntityTest type.

  • 🇦🇺Australia dpi Perth, Australia

    Updated summary to reduce pointing to Node

  • 🇮🇳India manishsaharan29497 New Delhi

    Re-rolled patch for 11.x. Keeping this in "Needs work" to update the test as per #62.

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update 12 months ago
    29,414 pass, 2 fail
  • 🇮🇳India vsujeetkumar Delhi

    Addressed #61 "Should we add an assert here that the status code is a 200?".
    Patch created, Keeping this in "Needs work" as we have failed test cases.

  • last update 9 months ago
    30,043 pass, 3 fail
  • 🇮🇳India vsujeetkumar Delhi

    Fixing Test cases, Please have a look. Keeps in "Needs Work" having some fail tests.

  • last update 9 months ago
    30,146 pass
  • Status changed to Needs review 9 months ago
  • 🇮🇳India vsujeetkumar Delhi

    Test passed, Moving to needs review. Please have a look.

  • 🇬🇧United Kingdom joachim

    Looks good, though I'm curious about the reason for these guards:

    1. +++ b/core/modules/comment/src/Entity/CommentType.php
      @@ -103,4 +103,22 @@ public function getTargetEntityTypeId() {
      +    if ($type) {
      

      What does it mean if $type is empty?

    2. +++ b/core/modules/comment/src/Entity/CommentType.php
      @@ -103,4 +103,22 @@ public function getTargetEntityTypeId() {
      +      if (\Drupal::moduleHandler()->moduleExists($provider)) {
      

      What does it mean if the provider module does not exist?

  • Status changed to Needs work 9 months ago
  • 🇺🇸United States smustgrave

    Seems upgrade path tests are still needed.

Production build 0.69.0 2024