diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php index f4132279e7e..e3af1b5eff6 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php @@ -169,9 +169,9 @@ abstract class EntityReferenceFormatterBase extends FormatterBase { /** * Checks access to the given entity. * - * By default, entity access is checked. However, a subclass can choose to - * exclude certain items from entity access checking by immediately granting - * access. + * By default, entity 'view' access is checked. However, a subclass can choose + * to exclude certain items from entity access checking by immediately + * granting access. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to check. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index 2084339f911..4cb5d149004 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldFormatter; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; @@ -100,4 +101,11 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase { return $elements; } + /** + * {@inheritdoc} + */ + protected function checkAccess(EntityInterface $entity) { + return $entity->access('view label', NULL, TRUE); + } + } diff --git a/core/modules/system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz b/core/modules/system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz index 615b88a7d45..d7f880d07a3 100644 Binary files a/core/modules/system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz and b/core/modules/system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz differ diff --git a/core/modules/system/tests/fixtures/update/drupal-8.filled.standard.php.gz b/core/modules/system/tests/fixtures/update/drupal-8.filled.standard.php.gz index 1b3e2396553..b3f2afb3002 100644 Binary files a/core/modules/system/tests/fixtures/update/drupal-8.filled.standard.php.gz and b/core/modules/system/tests/fixtures/update/drupal-8.filled.standard.php.gz differ diff --git a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php index df97a798eed..e6b670cfa38 100644 --- a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php +++ b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php @@ -54,9 +54,7 @@ class AuthorFormatter extends EntityReferenceFormatterBase { * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity) { - // Always allow an entity author's username to be read, even if the current - // user does not have permission to view the entity author's profile. - return AccessResult::allowed(); + return $entity->access('view label', NULL, TRUE); } }