1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-04 12:17:35 +02:00

Suppress errors when json_encode has ignoreErrors set

This commit is contained in:
Jordi Boggiano
2019-11-12 22:13:21 +01:00
parent 05f6ed7205
commit dc2895c80d

View File

@@ -38,13 +38,17 @@ class Utils
$encodeFlags = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
}
$json = json_encode($data, $encodeFlags);
if (false === $json) {
if ($ignoreErrors) {
$json = @json_encode($data, $encodeFlags);
if (false === $json) {
return 'null';
}
return $json;
}
$json = json_encode($data, $encodeFlags);
if (false === $json) {
$json = self::handleJsonError(json_last_error(), $data);
}