Call to a member function getFilename() on null

Created on 10 June 2024, 18 days ago

Problem/Motivation

When trying to edit a media entity that references an orphaned file entity, the following fatal error occurs:

Error: Call to a member function getFilename() on null in Drupal\media_name\MediaName->mediaEditFormSubmitHandler() (line 98 of /app/drupal/docroot/modules/contrib/media_name/src/MediaName.php).

This happens because MediaName::getMediaFile() can return NULL but its type is not checked.

Steps to reproduce

  • Create a media entity
  • Delete its corresponding file entity.
  • Try to update the media entity to replace the missing file.

Proposed resolution

Check the return value.

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡¬Bulgaria pfrenssen Sofia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024