$field['name'] may be undefined in file_entity_field_formatter_view in full file view mode

Created on 5 October 2020, about 4 years ago
Updated 26 January 2023, almost 2 years ago

Problem/Motivation

Prevent watchdog notices when rendering the page view of a file managed document type file.

Steps to reproduce

Upload a pdf document file, view if in the full view mode, at the file/[fid] URl and watch for watchdog messages of the like :

Notice : Trying to access array offset on value of type null in file_entity_field_formatter_view() (line 399 in /var/www/html/sites/all/modules/contrib/file_entity/file_entity.field.inc).

My issue may be tricky to reproduce as I have recently migrated from a very old File entity and Media versions on my 8 year old site.

Drupal 7.73
Media 7.x-2.26
File Entity 7.x-2.30

Using Entity translation on the file bundle fields.

Proposed resolution

Validate the existence of the key 'name' on the $field argument before usage in file_entity_field_formatter_view.

Remaining tasks

Improve this first patch so as to let the repeated file rendering prevention code run even without a value on the $field['name'] key.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇨🇦Canada tondeuse

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024