Call to a member function getFilename() on null

Created on 10 June 2024, 7 months 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.71.5 2024