Преглед изворни кода

set json flags correctly for SlackRecord, fixes #1396, closes #1397

Jordi Boggiano пре 6 година
родитељ
комит
ec3e0e3f90
1 измењених фајлова са 6 додато и 2 уклоњено
  1. 6 2
      src/Monolog/Handler/Slack/SlackRecord.php

+ 6 - 2
src/Monolog/Handler/Slack/SlackRecord.php

@@ -208,13 +208,17 @@ class SlackRecord
     {
         $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);
     }
 
     /**