Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stefanruijsenaars/e890de21949d1d21b86ed937d190a4ea to your computer and use it in GitHub Desktop.
Save stefanruijsenaars/e890de21949d1d21b86ed937d190a4ea to your computer and use it in GitHub Desktop.
diff -u b/core/modules/comment/src/CommentFieldItemList.php b/core/modules/comment/src/CommentFieldItemList.php
--- b/core/modules/comment/src/CommentFieldItemList.php
+++ b/core/modules/comment/src/CommentFieldItemList.php
@@ -51,8 +51,11 @@
}
if ($operation === 'view') {
// Only users with either post comments or access comments permisison can
- // view the field value. The formatter takes care of showing the comment
- // thread and form based on the individual permissions.
+ // view the field value. The formatter,
+ // Drupal\comment\Plugin\Field\FieldFormatter\CommentDefaultFormatter,
+ // takes care of showing the thread and form based on individual
+ // permissions, so if a user only has ‘post comments’ access, only the
+ // form will be shown and not the comments.
$result = AccessResult::allowedIfHasPermission($account ?: \Drupal::currentUser(), 'access comments')
->orIf(AccessResult::allowedIfHasPermission($account ?: \Drupal::currentUser(), 'post comments'));
return $return_as_object ? $result : $result->isAllowed();
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment