Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBase::mimeTypeApplies() (line 171 of Plugin/Field/FieldFormatter/FileMediaFormatterBase.php)

Created on 7 August 2024, 6 months ago

Problem/Motivation

If the list of allowed file extensions for a file field includes an unknown file extension, such as "foobaz", an error will be logged when viewing the rendered file field: Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBase::mimeTypeApplies() (line 171 of core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php)

Steps to reproduce

I suspect the list of allowed file extensions is processed in order, so the unknown file extension needs to precede the file extension used by the rendered file field. For example, set the allowed file extensions for a file field to "foobaz, mp3" and then create an entity with an attached mp3 file. The error will be logged when rendering the entity.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
File systemย  โ†’

Last updated 31 minutes ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mfb San Francisco

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

Comments & Activities

Production build 0.71.5 2024