.../src/Plugin/Field/FieldFormatter/ImageFormatterBase.php | 2 +- .../user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php index dd8348e..076b9d4 100644 --- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php @@ -19,7 +19,7 @@ /** * {@inheritdoc} */ - protected function getEntitiesToView(EntityReferenceFieldItemListInterface $items) { + protected function getEntitiesToView(EntityReferenceFieldItemListInterface &$items) { // Add the default image if needed. if ($items->isEmpty()) { $default_image = $this->getFieldSetting('default_image'); diff --git a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php index 674b936..10e488a 100644 --- a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php +++ b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php @@ -7,9 +7,11 @@ namespace Drupal\user\Plugin\Field\FieldFormatter; +use Drupal\Core\Access\AccessResult; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase; +use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; /** * Plugin implementation of the 'author' formatter. @@ -53,4 +55,13 @@ public static function isApplicable(FieldDefinitionInterface $field_definition) return $field_definition->getFieldStorageDefinition()->getSetting('target_type') == 'user'; } + /** + * {@inheritdoc} + */ + protected function checkAccess(EntityReferenceItem $item) { + // 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(); + } + }