Skip to content

Commit 646f1e2

Browse files
Merge branch '4.4'
* 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
2 parents af83545 + e83bad5 commit 646f1e2

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CHANGELOG
1515
* added `TraceableHttpClient`, `HttpClientDataCollector` and `HttpClientPass` to integrate with the web profiler
1616
* allow enabling buffering conditionally with a Closure
1717
* allow option "buffer" to be a stream resource
18+
* allow arbitrary values for the "json" option
1819

1920
4.3.0
2021
-----

CurlHttpClient.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,20 @@ public function stream($responses, float $timeout = null): ResponseStreamInterfa
327327
public function __destruct()
328328
{
329329
$this->multi->pushedResponses = [];
330-
if (\defined('CURLMOPT_PUSHFUNCTION')) {
331-
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
332-
}
333330

334-
$active = 0;
335-
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
331+
if (\is_resource($this->multi->handle)) {
332+
if (\defined('CURLMOPT_PUSHFUNCTION')) {
333+
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
334+
}
335+
336+
$active = 0;
337+
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
338+
}
336339

337340
foreach ($this->multi->openHandles as [$ch]) {
338-
curl_setopt($ch, CURLOPT_VERBOSE, false);
341+
if (\is_resource($ch)) {
342+
curl_setopt($ch, CURLOPT_VERBOSE, false);
343+
}
339344
}
340345
}
341346

HttpClientTrait.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,14 @@ private static function normalizePeerFingerprint($fingerprint): array
332332
}
333333

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

343-
if (!\is_array($value) && !$value instanceof \JsonSerializable) {
344-
throw new InvalidArgumentException(sprintf('Option "json" must be array or JsonSerializable, %s given.', \is_object($value) ? \get_class($value) : \gettype($value)));
345-
}
346-
347343
try {
348344
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth);
349345
} catch (\JsonException $e) {

HttpOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function setBody($body)
8686
}
8787

8888
/**
89-
* @param array|\JsonSerializable $json
89+
* @param mixed $json
9090
*
9191
* @return $this
9292
*/

0 commit comments

Comments
 (0)