Missing image file can stop block from being saved

Created on 5 August 2024, 4 months ago
Updated 22 August 2024, 3 months ago

Problem/Motivation

When using stage_file_proxy, if the partner item file can't be found, the block can not be saved and no error is thrown on the form. Watchdog reports:

Warning: Attempt to read property "field_media_image" on null in lb_partners_blocks_preprocess_block__lb_partners() (line 57 of /var/www/docroot/modules/contrib/lb_partners_blocks/lb_partners_blocks.module)

Warning: Attempt to read property "entity" on null in lb_partners_blocks_preprocess_block__lb_partners() (line 57 of /var/www/docroot/modules/contrib/lb_partners_blocks/lb_partners_blocks.module)

Error: Call to a member function createFileUrl() on null in lb_partners_blocks_preprocess_block__lb_partners() (line 57 of /var/www/docroot/modules/contrib/lb_partners_blocks/lb_partners_blocks.module)

Steps to reproduce

- Create a Partner block
- Add a new item
- Add a media item whose file is in the db but missing from the filesystem

Proposed resolution

Check that the entity can be referenced before calling createFileUrl

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States froboy Chicago, IL

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