Skip to content

Commit

Permalink
bug #31871 [HttpClient] revert bad logic around JSON_THROW_ON_ERROR (…
Browse files Browse the repository at this point in the history
…nicolas-grekas)

This PR was merged into the 4.3 branch.

Discussion
----------

[HttpClient] revert bad logic around JSON_THROW_ON_ERROR

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Same as #31869, reverts #31861

Commits
-------

846116e [HttpClient] revert bad logic around JSON_THROW_ON_ERROR
  • Loading branch information
fabpot committed Jun 5, 2019
2 parents 3242392 + 846116e commit 28fbf16
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/Symfony/Component/HttpClient/HttpClientTrait.php
Expand Up @@ -301,13 +301,7 @@ private static function jsonEncode($value, int $flags = null, int $maxDepth = 51
}

try {
if (\PHP_VERSION_ID >= 70300) {
// Work around https://bugs.php.net/77997
json_encode(null);
$flags |= JSON_THROW_ON_ERROR;
}

$value = json_encode($value, $flags, $maxDepth);
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth);
} catch (\JsonException $e) {
throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage()));
}
Expand Down
Expand Up @@ -148,7 +148,7 @@ public function toArray(bool $throw = true): array
}

try {
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0));
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0));
} catch (\JsonException $e) {
throw new JsonException($e->getMessage(), $e->getCode());
}
Expand Down

0 comments on commit 28fbf16

Please sign in to comment.