Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit62bd762

Browse files
Fix json-encoding when JSON_THROW_ON_ERROR is used
1 parent2ae0580 commit62bd762

File tree

6 files changed

+7
-29
lines changed

6 files changed

+7
-29
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,6 @@ private function writeData(array $data, array $options)
186186
{
187187
$flags =isset($options['json_encoding']) ?$options['json_encoding'] :0;
188188

189-
if (\PHP_VERSION_ID >=70300 && (JSON_THROW_ON_ERROR &$flags)) {
190-
// Work around https://bugs.php.net/77997
191-
json_encode(null);
192-
}
193-
194189
$this->write(json_encode($data,$flags |JSON_PRETTY_PRINT)."\n");
195190
}
196191

‎src/Symfony/Component/Console/Descriptor/JsonDescriptor.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ private function writeData(array $data, array $options)
9999
{
100100
$flags =isset($options['json_encoding']) ?$options['json_encoding'] :0;
101101

102-
if (\PHP_VERSION_ID >=70300 && (JSON_THROW_ON_ERROR &$flags)) {
103-
// Work around https://bugs.php.net/77997
104-
json_encode(null);
105-
}
106-
107102
$this->write(json_encode($data,$flags));
108103
}
109104

‎src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ private function writeData(array $data, array $options)
8383
{
8484
$flags =isset($options['json_encoding']) ?$options['json_encoding'] :0;
8585

86-
if (\PHP_VERSION_ID >=70300 && (JSON_THROW_ON_ERROR &$flags)) {
87-
// Work around https://bugs.php.net/77997
88-
json_encode(null);
89-
}
90-
9186
$this->output->write(json_encode($data,$flags |JSON_PRETTY_PRINT)."\n");
9287
}
9388

‎src/Symfony/Component/HttpFoundation/JsonResponse.php‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ public function setData($data = [])
153153
restore_error_handler();
154154
}
155155
}else {
156-
if (\PHP_VERSION_ID >=70300 && (JSON_THROW_ON_ERROR &$this->encodingOptions)) {
157-
// Work around https://bugs.php.net/77997
158-
json_encode(null);
159-
}
160-
161156
try {
162157
$data =json_encode($data,$this->encodingOptions);
163158
}catch (\Exception$e) {
@@ -166,6 +161,10 @@ public function setData($data = [])
166161
}
167162
throw$e;
168163
}
164+
165+
if (\PHP_VERSION_ID >=70300 && (JSON_THROW_ON_ERROR &$this->encodingOptions)) {
166+
return$this->setJson($data);
167+
}
169168
}
170169
}
171170

‎src/Symfony/Component/Serializer/Encoder/JsonEncode.php‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ public function encode($data, $format, array $context = [])
3636
{
3737
$context =$this->resolveContext($context);
3838

39+
$encodedJson =json_encode($data,$context['json_encode_options']);
40+
3941
if (\PHP_VERSION_ID >=70300 && (JSON_THROW_ON_ERROR &$context['json_encode_options'])) {
40-
// Work around https://bugs.php.net/77997
41-
json_encode(null);
42+
return$encodedJson;
4243
}
4344

44-
$encodedJson =json_encode($data,$context['json_encode_options']);
45-
4645
if (JSON_ERROR_NONE !==json_last_error() && (false ===$encodedJson || !($context['json_encode_options'] &JSON_PARTIAL_OUTPUT_ON_ERROR))) {
4746
thrownewNotEncodableValueException(json_last_error_msg());
4847
}

‎src/Symfony/Component/Translation/Dumper/JsonFileDumper.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti
3131
$flags =\defined('JSON_PRETTY_PRINT') ?JSON_PRETTY_PRINT :0;
3232
}
3333

34-
if (\PHP_VERSION_ID >=70300 && (JSON_THROW_ON_ERROR &$flags)) {
35-
// Work around https://bugs.php.net/77997
36-
json_encode(null);
37-
}
38-
3934
returnjson_encode($messages->all($domain),$flags);
4035
}
4136

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp