- Issue created by @msypes
- ๐ฎ๐ณIndia Sahana _N
sahana _n โ made their first commit to this issueโs fork.
- Status changed to Needs review
3 months ago 1:05pm 3 September 2024 - ๐ฎ๐ณIndia Sahana _N
Hi,
I can reproduce the issue in Drupal 10.3.x, when I attempt to view the page with a file reference to a file with NULL as the mimetype I got this error TypeError: Drupal\file\IconMimeTypes::getIconClass(): Argument #1 ($mimeType) must be of type string, null given, called in /var/www/html/core/modules/file/file.module on line 774 in Drupal\file\IconMimeTypes::getIconClass() (line 21 of core/modules/file/src/IconMimeTypes.php).I tested the same scenario by applying the patch provided in comment #3 (update this comment number). The patch is applied cleanly and the error was cleared. So, I created MR with the same code changes.
I am attaching before & after screenshots for reference.
This issue is also reproducible in 11.x and was able to fix the issue with the same code changes.
I'll be happy to create MR for 11.x also if required. Please suggest how we can proceed further.
- Status changed to Needs work
3 months ago 2:04pm 3 September 2024 - ๐บ๐ธUnited States smustgrave
Fixes should be against 11.x
Also we should probably do some debugging vs putting a null check. Could be masking a larger issue
- ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
Despite the db column allowing NULL. our API assumes there will always be a mime type. Why do you have NULL mimetypes?
- ๐บ๐ธUnited States msypes
@kim.pepper: Are you asking me why we had NULL mimetypes in the database? I don't know. Could be from a less-than-perfect migration, from when we moved from D7. They were generally pretty old records. Did the the API always assume there was a mimetype? If not, why would the db allow it to be NULL? At any rate, the fact that it does allow NULLs should mean that the system can handle them.