Problem/Motivation

Comment settings Closed option unavailable despite current value is Closed.

Noticed this after migrating nodes from d7.

Migrated node has comment settings = Closed, but on node edit form the Closed option is unavailable/does not show.

Proposed resolution

There's a type mistmatch between $element['status']['#default_value'] and CommentItemInterface::CLOSED at core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php:56.

Maybe just cast the prior to int or not use strict comparison !=?

// Only hide the option when it's not the currently selected option.
if ((int) $element['status']['#default_value'] !== CommentItemInterface::CLOSED) {
  $element['status'][CommentItemInterface::CLOSED]['#access'] = FALSE;
}
CommentFileSizeAuthor
#2 3485467-2.patch911 bytesdrpldrp
no-default-value-example.png63.15 KBdrpldrp

Comments

drpldrp created an issue. See original summary.

drpldrp’s picture

StatusFileSize
new911 bytes
drpldrp’s picture

drpldrp’s picture

Issue summary: View changes
lauriii’s picture

Thank you for opening the issue @drpldrp! If you have a chance, it would be great if you could file a merge request since our CI doesn't work with patches anymore. 😊

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.