- Issue created by @mfb
- First commit to issue fork.
- Merge request !9175Issue 3467501: update mime type for key file extension → (Open) created by annmarysruthy
- Status changed to Needs work
about 2 months ago 5:53pm 12 August 2024 - 🇺🇸United States mfb San Francisco
@annmarysruthy the array of file extensions should be in order by the numeric value.
We're going to need to add the other extensions too, but idk what they are supposed to be - maybe same as their od* equivalent, but add a "+xml" on the end because it's XML? Just a wild guess. If we can't find the mapping specified/documented somewhere, we could copy from some other package that maintains a mapping.
- 🇺🇸United States mfb San Francisco
Looks like various packages have the suffix as "-flat-xml" rather than "+xml", so I'd go with that as my best guess
- First commit to issue fork.
- Status changed to Needs review
14 days ago 6:15pm 13 September 2024 - Status changed to Needs work
14 days ago 10:41pm 13 September 2024 - 🇺🇸United States smustgrave
Thanks for reporting.
Noticed that the issue summary appears incomplete so tagged for that.
Also will need some kind of test case added to show the issue.
- Status changed to Needs review
14 days ago 10:49pm 13 September 2024 - 🇺🇸United States mfb San Francisco
@smustgrave There is already test coverage of the extension to MIME type mapping, so I don't think additional test coverage is needed here.
- 🇺🇸United States smustgrave
If it already had tests though then why is the change needed? Shouldn't the tests of caught the bug?
- 🇺🇸United States mfb San Francisco
@smustgrave What did you have in mind? You wouldn't want to add a test for each of the ~369 mappings. It's just a couple big flat arrays.
- 🇺🇸United States mark_fullmer Tucson
What did you have in mind? You wouldn't want to add a test for each of the ~369 mappings.
I agree that this doesn't seem like a typical thing that Drupal core would add test coverage for, namely, a test that verifies that all of the extensions defined in the
standard
installation profile's media types are present in the MimeTypeGuesser array. I think automated test coverage *would* be more appropriate for 🐛 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) Needs work , to demonstrate that when unknown file types are declared, they do not trigger a PHP warning, and/or are handled through appropriate form validation.So, for this issue, I think it might be most appropriate to start by adding steps to reproduce, to show what "problem" there is when the MimeTypeGuesser does not include some of the file extensions defined in the
standard
installation profile'sdocument
media type configuration. Something like:- Install the "standard" installation profile
- Enable the media_library module
- Go to Structure > Media Types > Document > Edit > Manage display
- [Describe resulting problem]
- 🇺🇸United States mfb San Francisco
Added steps to reproduce to the issue summary.
I was thinking of this from the perspective of just missing data, like if a language was missing from the array of languages in LanguageManager.php, as Drupal maintains a mapping of known file extensions and MIME types, and file extensions can be configured manually. (Of course neither languages nor file extensions/MIME types are an exhaustive list, as they are only added when someone notices them missing..)
- 🇺🇸United States smustgrave
If we are re-mapping here are there others to be checked?
- 🇺🇸United States mfb San Francisco
We could create a followup issue to do something like.. create a script to audit/compare drupal's mapping vs. the MIME type databases typically found in operating system distributions? There are actually at least two such databases: The /etc/mime.types file and the /usr/share/mime directory.
- 🇺🇸United States mfb San Francisco
...and it looks like there is already a third-party tool pretty similar to what I mentioned - the fileeye-mimemap update utility retrieves MIME types from both Apache and freedesktop.org, merges them, and generates a map. This library could be incorporated as a runtime third-party dependency, or at least be leveraged to help maintain the existing mapping.