[9.x] Avoid throwing on invalid mime-type #42761
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
league/flysystem
version 3, changed to throw exceptions in places it previously returnednull
orfalse
when a called method failed to execute.As noted by issue #42758 , calling
Illuminate\Filesystem\FilesystemAdapter@mimeType
throws an exception when a file has a custom extension.This becomes a problem when this method is called within other methods such in:
framework/src/Illuminate/Filesystem/FilesystemAdapter.php
Line 278 in 2bc1802
framework/src/Illuminate/Mail/Attachment.php
Line 98 in 2bc1802
framework/src/Illuminate/Mail/Mailable.php
Line 463 in 2bc1802
Disclaimer: usage on
Illuminate\Filesystem\FilesystemAdapter@response
is changed to be lazily evaluated in PR #42760This PR
Illuminate\Filesystem\FilesystemAdapter@mimeType
to returnfalse
, as per its docblock, when the mime type cannot be detectedthrow
configuration, when a developer sets it totrue
an exception will be thrown insteadEDIT
As
league/flysystem
changed the mime type detection behavior on tag 3.0.16, I updated thecomposer.json
file to require at least this version.Otherwise tests with prefer-lowest were failing