Fix MimeTypeGuesser::guessMimeType() return value

Created on 18 June 2021, over 3 years ago
Updated 5 June 2024, 7 months ago

Problem/Motivation

MimeTypeGuesser::guessMimeType() is typed to return "?string" (string or null) but it returns void if no guesser can find a matching value.

This leads to a TypeError when using PHP 8:

The website encountered an unexpected error. Please try again later.
TypeError: Drupal\Core\File\MimeType\MimeTypeGuesser::guessMimeType(): Return value must be of type ?string, none returned in Drupal\Core\File\MimeType\MimeTypeGuesser->guessMimeType() (line 76 of core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php).

That method should return NULL (or a default MimeType) if nothing found.

πŸ› Bug report
Status

Closed: outdated

Version

11.0 πŸ”₯

Component
File systemΒ  β†’

Last updated 3 days ago

Created by

πŸ‡ͺπŸ‡ΈSpain albertosilva Basque Country

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