8000 [JsonResponse] Silent only JSON errors by GromNaN · Pull Request #11418 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[JsonResponse] Silent only JSON errors #11418

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Clear json_last_error
  • Loading branch information
GromNaN committed Sep 15, 2014
commit c2a1a5b0918eb9d904877b68f69054bfe70a0c1a
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpFoundation/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public function setData($data = array())
});

try {
// Clear json_last_error()
json_encode(null);

$this->data = json_encode($data, $this->encodingOptions);

restore_error_handler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ public function testSetContent()
}

/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage This error is expected
* @expectedException Exception
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning is converted to an exception by PHPUnit.

* @expectedExceptionMessage Failed calling Symfony\Component\HttpFoundation\Tests\JsonSerializableObject::jsonSerialize()
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php#114688
*/
public function testSetContentJsonSerializeError()
{
Expand Down
0