The assumption made here, in comment_form_node_form_alter(), is incorrect.
// If the node doesn't have any comments, the "hidden" option makes no
// sense, so don't even bother presenting it to the user.
if (empty($comment_count)) {
$form['comment_settings']['comment'][COMMENT_NODE_HIDDEN]['#access'] = FALSE;
// Also adjust the description of the "closed" option.
$form['comment_settings']['comment'][COMMENT_NODE_CLOSED]['#description'] = t('Users cannot post comments.');
}
Comments being closed and comments being hidden are different states, and users should be allowed to choose between them. For instance, if a collection of nodes did have commenting available for a period of time, and now commenting is closed, then I may want to show the number of comments per node. Zero is a valid number of comments. But if I want to remove all trace that commenting ever happened on those nodes, then I want to be able to change their status from CLOSED to HIDDEN. It's like the difference between zero and NULL.
This whole IF block should be removed.
Comment | File | Size | Author |
---|---|---|---|
#4 | comment-hidden-2140251-4.patch | 1.62 KB | brad.bulger |
#1 | comment-2140251-hidden.patch | 781 bytes | brad.bulger |
Comments
Comment #1
brad.bulger CreditAttribution: brad.bulger commentedPatch file to remove this code.
Comment #3
mirie CreditAttribution: mirie commentedI agree with this proposal completely. I also noticed that the default value also has funky logic. In comment_form_node_form_alter(), line 1223:
I found out about this because I implemented my own hook_form_BASE_FORM_ID_alter() for the node form to override the comment hidden issue. That meant that even though I made the hidden comment option accessible and saved the node with hidden selected, on the next refresh of that node edit form, the value selected for comments was Closed because the node didn't have any comments! That seems like unexpected behavior to me...I was surprised.
Comment #4
brad.bulger CreditAttribution: brad.bulger commentedAh, I just ran into this. Yes, it resets the mode from Hidden to Closed because reasons (???) and makes comment links appear when they ought not to. You have to manually reset it every time. That's just wrong.
If the node's own comment property is not set, it should use the default for the content type.
I've added that in and redone the patch.
Comment #5
brad.bulger CreditAttribution: brad.bulger commentedComment #6
dcam CreditAttribution: dcam commentedThis code that is causing the original issue still exists in Drupal 8. See formElement() in /core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php. That means the change will need to be made to Drupal 8 first.
Comment #7
dcam CreditAttribution: dcam commentedActually, since this is considered a bug then it may be possible to get this fixed for 8.0.x.
Comment #16
quietone CreditAttribution: quietone as a volunteer commentedThe code in question does not exist in Drupal 9.3.x. It was removed on 27 Sept 2013 before this issue was opened. I think it was Drupal 8.0-alpha4, #731724: Convert comment settings into a field to make them work with CMI and non-node entities.
Moving to Drupal 7.