Call to a member function getFileUri() on null in Drupal\media_directories_editor\Plugin\Field\FieldFormatter\MediaDirectoriesImageDimensionsFormatter->viewElements()

Created on 27 September 2024, about 2 months ago

Problem/Motivation

We ran into a weird problem.
On one project, we see the following error:
Error: Call to a member function getFileUri() on null in Drupal\media_directories_editor\Plugin\Field\FieldFormatter\MediaDirectoriesImageDimensionsFormatter->viewElements() (line 234 of modules\contrib\media_directories\modules\media_directories_editor\src\Plugin\Field\FieldFormatter\MediaDirectoriesImageDimensionsFormatter.php).
When I started to dig further, I noticed that the image was removed from some media (in fact, the file was deleted, and the media was left without a file).
In this task, I will not describe why the file was deleted, I am sure it is not related to the "media_directories" module.
However, I am proposing to add extra checking.

      if (!$file instanceof FileInterface) {
        return $elements;
      }
🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇺🇦Ukraine Ruslan Piskarov Kiev, Ukraine

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