Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpFoundation] Support root-level Generator in StreamedJsonResponse#51538
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
derrabus commentedSep 3, 2023
Thank you. Please be aware that we never merge new features without any tests. |
280e92d tod34e28fCompareJeroeny commentedSep 4, 2023
@derrabus Thanks for the hint, added tests. |
nicolas-grekas left a comment
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.
Thanks for the PR. Please add a line about this to the changelog of the component.
Jeroeny commentedSep 14, 2023
Added the changelog entry |
fabpot commentedOct 1, 2023
Thank you@Jeroeny. |
Uh oh!
There was an error while loading.Please reload this page.
Currently the
StreamedJsonResponseonly supports streaming nested Generators within an array data structure.However if a response is a list of items (for example database entities) on the root level, this isn't usable.
I think both usecases can be supported with the change in this PR.
The root level generator doesn't account for additional nested generators yet. I could add that by doing
is_array($item)and the call the recursive placeholder logic.Link to first PR that introduced StreamedJsonResponse:#47709
Also something I noticed is I only got intermediate output, when adding aEdit: I see the class' PhpDoc describes this and it's probably expected to be done in userland implementations.flush()call after each item has been echo'd (with asleep(1)after each item to see it output the parts individually).