Clean-up CommentManager::getFields() function signature/invocations

Created on 14 September 2014, almost 10 years ago
Updated 30 January 2023, over 1 year ago

comment_entity_insert() says

  if (... && $fields = \Drupal::service('comment.manager')->getFields($entity->getEntityTypeId())) {
    \Drupal::service('comment.statistics')->create($entity, array_keys($fields));
  }

This potentially creates too many comment.statistics thingies, because it doesn't check properly if $fields exist in $entity.

This (imho) signifies a need for adding an optional $bundle parameter to getFields. Better DX, it serves as a visible sign that you actually need to check whether the fields exists in $entity's specific bundle.

In addition to that, other invocations of getFields() should get checked to see if there are more 'bugs' there.

(Not sure how 'novice' this is, but I (mentoring) can probably use it in Amsterdam unless someone wants to pick it up first. If it's still open after Amsterdam I'll pick it up.)

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
CommentΒ  β†’

Last updated 2 days ago

Created by

πŸ‡³πŸ‡±Netherlands roderik Amsterdam,NL / Budapest,HU

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.69.0 2024