-
-
Notifications
You must be signed in to change notification settings - Fork 950
fix(symfony): retain existing associations of formats to MIME types when adding new MIME types #6833
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
Merged
Merged
fix(symfony): retain existing associations of formats to MIME types when adding new MIME types #6833
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we think it'd be best to restore Symfony formats to the value it was initially when the request is done (for example in the ResponseProcessor ?). Doing this may allow some unwanted formats in the next request. ping @dunglas
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't know the internals of API Platform well enough to say this fix won't have side-effects on how the system reads MIME types elsewhere, so I can understand the concern. To fix the best way possible I think will unfortunately be a fair bit more effort, because you'll need to read the MIME types for every supported format at the beginning of a request, store that state somewhere, then restore it at the end of every master request. Symfony doesn't provide an interface to iterate or read its internal formats mapping, you can only request it either per-format or per-mimetype onRequest's public API.Edit: having gone through a fair portion of the code today and the test suite, I don't think this change introduces any new problems. API Platform is explicit about injecting the preferred format on every request, so the only issue I can identify is the one this fixes, where request formats are being overwritten in long-running servers rather than expanded. I don't think you will see any benefit to any process of resetting the static
Requestformats on every request.This is only a mapping of formats to supported MIME types, and the one(s) you're putting in here will always take precedence over the existing formats, which seems like it should be the behaviour you want. Consider:
So you should always be getting the right ordering for the format. You can see this PR hasn't broken your test suite, which is a good sign.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely a good sign as we have some weird tests in there haha