-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Handle nullable callback of StreamedResponse
#51972
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
Conversation
StreamedResponse
Thank you @elementaire. |
{ | ||
if (!isset($this->callback)) { |
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.
I would use null === $this->callback
for consistency with our other null checks
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.
isset() is what we use on 7.0 because the property is not declared as nullable
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.
but this whole ticket is about fixing the fact that the callback can be null. So to me, the 7.0 type should also be changed as part of this fix.
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.
btw, as the property is protected and not private, this is a BC break to turn it into a non-nullable potentially-uninitialized property as the way to represent an existing state.
…with null (xabbuh) This PR was merged into the 7.0 branch. Discussion ---------- [HttpFoundation] initialize protected callback property with null | Q | A | ------------- | --- | Branch? | 7.0 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #51972 (comment) | License | MIT Commits ------- b780c12 initialize protected callback property with null
This PR fixes a bug introduced by #51396. Having a callback in
StreamResponsed
is not a mandatory by design.So the method
getCallback
must check it likesendContent
does.When we are dealing with cacheable ressource, only headers are sent from
StreamResponsed
, for example:HttpKernel
class have to handle it else if you obtainHTTP 500
with messageValue of type null is not callable
.cc @nicolas-grekas
EDIT: found by @alexismarquis