Skip to content

Commit

Permalink
Merge pull request #2655 from MashinaMashina/patch-1
Browse files Browse the repository at this point in the history
Fix JSON error on recursion in data
  • Loading branch information
lonnieezell authored Mar 9, 2020
2 parents 837020c + 99a65a8 commit 5093694
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions system/Format/JSONFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ class JSONFormatter implements FormatterInterface
*/
public function format($data)
{
$options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
$options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR;

$options = ENVIRONMENT === 'production' ? $options : $options | JSON_PRETTY_PRINT;

$result = json_encode($data, $options, 512);

if (json_last_error() !== JSON_ERROR_NONE)
if ( ! in_array(json_last_error(), [JSON_ERROR_NONE, JSON_ERROR_RECURSION]))
{
throw FormatException::forInvalidJSON(json_last_error_msg());
}
Expand Down

0 comments on commit 5093694

Please sign in to comment.