Skip to content

Commit

Permalink
set json flags correctly for SlackRecord, fixes #1396, closes #1397
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 13, 2019
1 parent f97cc75 commit ec3e0e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Monolog/Handler/Slack/SlackRecord.php
Expand Up @@ -208,13 +208,17 @@ public function stringify($fields)
{
$normalized = $this->normalizerFormatter->format($fields);
$prettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128;
$flags = 0;
if (PHP_VERSION_ID >= 50400) {
$flags = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
}

$hasSecondDimension = count(array_filter($normalized, 'is_array'));
$hasNonNumericKeys = !count(array_filter(array_keys($normalized), 'is_numeric'));

return $hasSecondDimension || $hasNonNumericKeys
? Utils::jsonEncode($normalized, $prettyPrintFlag)
: Utils::jsonEncode($normalized);
? Utils::jsonEncode($normalized, $prettyPrintFlag | $flags)
: Utils::jsonEncode($normalized, $flags);
}

/**
Expand Down

0 comments on commit ec3e0e3

Please sign in to comment.