Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Avoid throwing on invalid mime-type #42761

Merged
merged 2 commits into from
Jun 13, 2022
Merged

[9.x] Avoid throwing on invalid mime-type #42761

merged 2 commits into from
Jun 13, 2022

Conversation

rodrigopedra
Copy link
Contributor

@rodrigopedra rodrigopedra commented Jun 11, 2022

league/flysystem version 3, changed to throw exceptions in places it previously returned null or false 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:

Disclaimer: usage on Illuminate\Filesystem\FilesystemAdapter@response is changed to be lazily evaluated in PR #42760

This PR

  • Changes Illuminate\Filesystem\FilesystemAdapter@mimeType to return false, as per its docblock, when the mime type cannot be detected
  • Honors the throw configuration, when a developer sets it to true an exception will be thrown instead
  • Adds two test cases covering both cases

EDIT

As league/flysystem changed the mime type detection behavior on tag 3.0.16, I updated the composer.json file to require at least this version.

Otherwise tests with prefer-lowest were failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants