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

Uploading unknown filetypes is no longer possible #572

Closed
edwilde opened this issue Oct 10, 2023 · 8 comments
Closed

Uploading unknown filetypes is no longer possible #572

edwilde opened this issue Oct 10, 2023 · 8 comments

Comments

@edwilde
Copy link
Contributor

edwilde commented Oct 10, 2023

This appears to be caused by league/flysystem v3 changing to throwing exceptions rather than returning null - see a similar issue in laravel.

I have added the appropriate configurations to allow brf (braille format) files, as per the documentation.

This works just fine in CMS 4.13, but fails in CMS 5.0 with the following error:

error-log.ERROR: Uncaught Exception League\Flysystem\UnableToRetrieveMetadata: "Unable to retrieve the mime_type for file at location: c7481fdf07/brf-sample.brf. " at /var/www/mysite/www/vendor/league/flysystem/src/UnableToRetrieveMetadata.php line 49 {"exception":"[object] (League\\Flysystem\\UnableToRetrieveMetadata(code: 0): Unable to retrieve the mime_type for file at location: c7481fdf07/brf-sample.brf.  at /var/www/mysite/www/vendor/league/flysystem/src/UnableToRetrieveMetadata.php:49)"} []

The exception is raised on the flysystem adapter and unhandled in the Silverstripe Asset store class.

That was fixed, released, and then rolled back. It is now an opt-in to fix that behaviour by passing a new argument to the constructor.

Acceptance Criteria

  • Pass true to the new opt-in argument in the FallbackMimeTypeDetector constructor.

NOTE

Once this has been resolved, we should raise a new PR to add #573 to the changelog.
No sense adding it until this is resolved.

PRs

@GuySartorelli GuySartorelli self-assigned this Oct 10, 2023
@GuySartorelli
Copy link
Member

Turns out this is a bug upstream: thephpleague/flysystem#1468
I've raised a PR to fix it: thephpleague/flysystem#1710

I'll keep this issue open in the meantime - if they decide they don't consider it to be a bug, we may need to work around it.

@GuySartorelli
Copy link
Member

The PR for flysystem has been merged - once a release has been tagged which includes that code I'll close this issue.

@GuySartorelli
Copy link
Member

Frustratingly, the bug was fixed and released - and then immediately they decided to unfix it and make it opt-in.
So we either have to bump the dependency (which we can't do in a patch) and pass in the new constructor argument to opt in to the fixed behaviour, or we have to implement a fix on our end which we can release as a patch.

I'll put this in our backlog to discuss.

@kinglozzer
Copy link
Member

This is created via LocalFilesystemAdapter, right? Could we add this line to __construct() in that class?

$mimeTypeDetector = $mimeTypeDetector ?? new FallbackMimeTypeDetector(new FinfoMimeTypeDetector(), true);

If anyone is using < 3.23.0 it shouldn’t cause any harm, the extra constructor arg will just be discarded.

@GuySartorelli
Copy link
Member

Right, that's exactly the opt-in behaviour I mention in my comment.

I forgot that constructor args are discarded if not used.... I guess we could ship that in a patch without bumping the dependency, then. We wouldn't be able to add a test for it though because the prefer-lowest build would fail.

@GuySartorelli
Copy link
Member

@edwilde I've raised a PR to opt-in to the bug fix. Would you like to create a PR to add the braille format change into the 5.2.0 changelog?

@emteknetnz
Copy link
Member

Linked PR has been merged, will be automatically patch released shortly

@edwilde
Copy link
Contributor Author

edwilde commented Jan 7, 2024

@GuySartorelli PR for the changelog update is added 🚀

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

No branches or pull requests

4 participants