Problem/Motivation

After unpublishing a media entity you'll get the following notice when you view the media entity if you haven't configured a fallback media entity:

Undefined index: #view_mode in Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (line 274 of core/lib/Drupal/Core/Entity/EntityViewBuilder.php).

In media_expire_media_build_defaults_alter() you set the build-Array to an empty array if no fallback is defined. This also clears the key #view_mode which is used in the EntityViewBuilder.

Steps to reproduce

  • create a media entity and set its status to "unpublished"
  • view the media entity

Proposed resolution

  • check if #view_mode is empty in MediaViewController::view and make sure it is set

Remaining tasks

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

stBorchert created an issue. See original summary.

stborchert’s picture

Issue summary: View changes
Status: Active » Needs review

chr.fritsch made their first commit to this issue’s fork.

  • chr.fritsch committed 9f4be3a on 8.x-2.x authored by stBorchert
    Issue #3211081 by stBorchert: Undefined index: #view_mode in Drupal\Core...
chr.fritsch’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.