Skip to content

Commit

Permalink
Merge branch '4.4'
Browse files Browse the repository at this point in the history
* 4.4:
  [DI] Dont cache classes with missing parents
  [HttpClient] Fix a crash when calling CurlHttpClient::__destruct()
  Unallow symfony/http-kernel ^5.0
  [FrameworkBundle] fix SodiumVault after stof review
  [HttpClient] allow arbitrary JSON values in requests
  [DependencyInjection] Added option `ignore_errors: not_found` while importing config files
  [Validator] Add the missing translations for the Hebrew (\"he\") locale and fix 2 typos
  [FrameworkBundle][Translation] Invalidate cached catalogues when the scanned directories change
  • Loading branch information
nicolas-grekas committed Nov 8, 2019
2 parents af83545 + e83bad5 commit 646f1e2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@ CHANGELOG
* added `TraceableHttpClient`, `HttpClientDataCollector` and `HttpClientPass` to integrate with the web profiler
* allow enabling buffering conditionally with a Closure
* allow option "buffer" to be a stream resource
* allow arbitrary values for the "json" option

4.3.0
-----
Expand Down
17 changes: 11 additions & 6 deletions CurlHttpClient.php
Expand Up @@ -327,15 +327,20 @@ public function stream($responses, float $timeout = null): ResponseStreamInterfa
public function __destruct()
{
$this->multi->pushedResponses = [];
if (\defined('CURLMOPT_PUSHFUNCTION')) {
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
}

$active = 0;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
if (\is_resource($this->multi->handle)) {
if (\defined('CURLMOPT_PUSHFUNCTION')) {
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
}

$active = 0;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
}

foreach ($this->multi->openHandles as [$ch]) {
curl_setopt($ch, CURLOPT_VERBOSE, false);
if (\is_resource($ch)) {
curl_setopt($ch, CURLOPT_VERBOSE, false);
}
}
}

Expand Down
6 changes: 1 addition & 5 deletions HttpClientTrait.php
Expand Up @@ -332,18 +332,14 @@ private static function normalizePeerFingerprint($fingerprint): array
}

/**
* @param array|\JsonSerializable $value
* @param mixed $value
*
* @throws InvalidArgumentException When the value cannot be json-encoded
*/
private static function jsonEncode($value, int $flags = null, int $maxDepth = 512): string
{
$flags = $flags ?? (JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION);

if (!\is_array($value) && !$value instanceof \JsonSerializable) {
throw new InvalidArgumentException(sprintf('Option "json" must be array or JsonSerializable, %s given.', \is_object($value) ? \get_class($value) : \gettype($value)));
}

try {
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth);
} catch (\JsonException $e) {
Expand Down
2 changes: 1 addition & 1 deletion HttpOptions.php
Expand Up @@ -86,7 +86,7 @@ public function setBody($body)
}

/**
* @param array|\JsonSerializable $json
* @param mixed $json
*
* @return $this
*/
Expand Down

0 comments on commit 646f1e2

Please sign in to comment.