- 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
3 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
2 months ago 6:15pm 13 September 2024 - Status changed to Needs work
2 months 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
2 months 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.
- ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
#17 sounds like a great idea. Created ๐ Generate file extension mime type map with fileeye/mimemap update utility Active
The Needs Review Queue Bot โ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide โ to find step-by-step guides for working with issues.
- ๐บ๐ธUnited States smustgrave
So since we don't have test coverage already and seems #18 mentions adding a way to auto do this I'm assuming coverage will be added there.
That case I believe this change is fine, will go out on a limb and RTBC it.