Fatal error if image file missing

Created on 1 April 2024, 8 months ago
Updated 15 April 2024, 7 months ago

Problem/Motivation

If an image file does not exist for some reason (such as the site being run in a local environment without all of the files downloaded from the live server) the field formatter throws a fatal error, due to `file_get_contents` being called with a blank string as its argument.

Steps to reproduce

Delete an image file from the files directory that is expected by an image field to be rendered using this formatter, or just run it in an environment where the image files are not

Proposed resolution

Something as simple as `if (empty($absolute_path)) { continue; }` before the `$image_file = file_get_contents($absolute_path);` line seems to prevent the fatal error.

However, some non-fatal error handling may be warranted, such as a adding message in the watchdog when a file is not found.

Remaining tasks

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇺🇸United States mikemccaffrey

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