Fix JSON serialization error on PHP 7

Closes #685.

Thanks to @sijad.
This commit is contained in:
Franz Liedke 2016-03-18 21:11:54 +09:00
parent 1ca1639139
commit 588dd7b213

View File

@ -22,6 +22,9 @@ class JsonApiResponse extends JsonResponse
{
$headers['content-type'] = 'application/vnd.api+json';
parent::__construct($document, $status, $headers, $encodingOptions);
// The call to jsonSerialize prevents rare issues with json_encode() failing with a
// syntax error even though Document implements the JsonSerializable interface.
// See https://github.com/flarum/core/issues/685
parent::__construct($document->jsonSerialize(), $status, $headers, $encodingOptions);
}
}