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

Catch exceptions when JSON decoding fails #110

Merged
merged 5 commits into from
Feb 13, 2025

Conversation

Toflar
Copy link
Member

@Toflar Toflar commented Feb 10, 2025

If somehow there's an error writing the config to the storage, you'll end up getting Uncaught PHP Exception Contao\Image\Exception\JsonException: "Syntax error" at DeferredImageStorageFilesystem.php line 210 because the has() check does not validate the syntax.

@ausi
Copy link
Member

ausi commented Feb 10, 2025

Shouldn’t this be handled by the storage itself instead?

@Toflar
Copy link
Member Author

Toflar commented Feb 10, 2025

Sure, I just quickly proposed a fix but can be different. You mean, has() should already check that? Because if has() returns true and then get() returns null anyway, that would be weird :D

@ausi
Copy link
Member

ausi commented Feb 11, 2025

You mean, has() should already check that? Because if has() returns true and then get() returns null anyway, that would be weird :D

I think the get() call should delete the file in the storage internally while still throwing the exception. The resizer should just ignore the exception.

I implemented this now and pushed to your branch, do you agree with my changes?

@Toflar
Copy link
Member Author

Toflar commented Feb 11, 2025

LGTM

@ausi ausi merged commit ec6eeb9 into contao:1.x Feb 13, 2025
20 checks passed
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.

3 participants