-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Jsonresponse fix #16551
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
Jsonresponse fix #16551
Conversation
…) when getContent is not empty
Added new tests for testing setting content and setting data after setting EncodingOptions
* jsonresponse-fix: [HttpFoundation] JsonResponse.php. Updated JsonResponseTest [HttpFoundation] JsonResponse.php. Updated setData() with getContent() when getContent is not empty
@@ -144,6 +144,10 @@ public function setEncodingOptions($encodingOptions) | |||
{ | |||
$this->encodingOptions = (int) $encodingOptions; | |||
|
|||
if ($this->content !== null) { | |||
$this->data = $this->content; |
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.
this looks wrong to me
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.
and btw, I don't see how your new tests are covering this
I think the bug is that it should decode |
and now, I agree that your test covers the bug. But the original test was not covering it |
@stof I see your point. However in I think it depends on what is leading, |
ah wait, But your fix is wrong. |
@stof JsonResponse has two ways of setting content, which can be misleading. JsonResponse being a subclass of Response (and some sort of a helperClass if you will), If public function setEncodingOptions($encodingOptions)
{
$this->encodingOptions = (int) $encodingOptions;
// when content is set by calling $this->setContent, instead of $this->data
if (!empty($this->content)) {
return $this->setData(json_decode($this->content));
}
return $this->setData(json_decode($this->data));
} public function addData($data) //instead setData
{
$this->data = $data;
$this->update();
} |
Fixed JsonResponse setContent after settinh encoding options
[HttpFoundation][JsonResponse.php] udated setData() with getContent() when getContent is not empty