Skip to content

Commit d4c0b28

Browse files
Merge branch '6.2' into 6.3
* 6.2: [Validator] Add missing validator translations in Polish language [HttpClient] Fix encoding some characters in query strings [SecurityBundle] Remove last usages of tag `security.remember_me_aware` [VarDumper] Dumping DateTime throws error if getTimezone is false Only update autoload_runtime.php when it changed [Intl] Update the ICU data to 73.2 [HttpClient] Force int conversion for floated multiplier for GenericRetryStrategy [FrameworkBundle] Ignore missing directories in about command Revert "[Messenger] Respect `isRetryable` decision of the retry strategy when deciding if failed message should be re-delivered" [Validator][Translator] Fix xlf files for en & fr translations. Bug introduced by #50590 Add missing EN and FR translations for newest constraints
2 parents 5b9fa4a + dc9945e commit d4c0b28

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

HttpClientTrait.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ private static function parseUrl(string $url, array $query = [], array $allowedS
659659
}
660660

661661
// https://tools.ietf.org/html/rfc3986#section-3.3
662-
$parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()[\]*+,;=:@\\\\^`{|}%]++#", fn ($m) => rawurlencode($m[0]), $parts[$part]);
662+
$parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()[\]*+,;=:@{}%]++#", fn ($m) => rawurlencode($m[0]), $parts[$part]);
663663
}
664664

665665
return [
@@ -748,11 +748,7 @@ private static function mergeQueryString(?string $queryString, array $queryArray
748748
'%3B' => ';',
749749
'%40' => '@',
750750
'%5B' => '[',
751-
'%5C' => '\\',
752751
'%5D' => ']',
753-
'%5E' => '^',
754-
'%60' => '`',
755-
'%7C' => '|',
756752
]);
757753
}
758754

Retry/GenericRetryStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function getDelay(AsyncContext $context, ?string $responseContent, ?Trans
102102
$delay = $this->delayMs * $this->multiplier ** $context->getInfo('retry_count');
103103

104104
if ($this->jitter > 0) {
105-
$randomness = $delay * $this->jitter;
105+
$randomness = (int) ($delay * $this->jitter);
106106
$delay = $delay + random_int(-$randomness, +$randomness);
107107
}
108108

Tests/HttpClientTraitTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,13 @@ public static function provideParseUrl(): iterable
269269
yield [['http:', '//example.com', null, null, null], 'http://Example.coM:80'];
270270
yield [['https:', '//xn--dj-kia8a.example.com:8000', '/', null, null], 'https://DÉjà.Example.com:8000/'];
271271
yield [[null, null, '/f%20o.o', '?a=b', '#c'], '/f o%2Eo?a=b#c'];
272+
yield [[null, null, '/custom%7C2010-01-01%2000:00:00%7C2023-06-15%2005:50:35', '?a=b', '#c'], '/custom|2010-01-01 00:00:00|2023-06-15 05:50:35?a=b#c'];
272273
yield [[null, '//a:b@foo', '/bar', null, null], '//a:b@foo/bar'];
273274
yield [[null, '//a:b@foo', '/b{}', null, null], '//a:b@foo/b{}'];
274275
yield [['http:', null, null, null, null], 'http:'];
275276
yield [['http:', null, 'bar', null, null], 'http:bar'];
276277
yield [[null, null, 'bar', '?a=1&c=c', null], 'bar?a=a&b=b', ['b' => null, 'c' => 'c', 'a' => 1]];
277-
yield [[null, null, 'bar', '?a=b+c&b=b-._~!$%26/%27()[]*%2B%2C;%3D:@%25\\^`%7B|%7D', null], 'bar?a=b+c', ['b' => 'b-._~!$&/\'()[]*+,;=:@%\\^`{|}']];
278+
yield [[null, null, 'bar', '?a=b+c&b=b-._~!$%26/%27()[]*%2B%2C;%3D:@%25%5C%5E%60%7B%7C%7D', null], 'bar?a=b+c', ['b' => 'b-._~!$&/\'()[]*+,;=:@%\\^`{|}']];
278279
yield [[null, null, 'bar', '?a=b%2B%20c', null], 'bar?a=b+c', ['a' => 'b+ c']];
279280
yield [[null, null, 'bar', '?a[b]=c', null], 'bar', ['a' => ['b' => 'c']]];
280281
yield [[null, null, 'bar', '?a[b[c]=d', null], 'bar?a[b[c]=d', []];

Tests/Retry/GenericRetryStrategyTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testGetDelay(int $delay, int $multiplier, int $maxDelay, int $pr
6767

6868
public static function provideDelay(): iterable
6969
{
70-
// delay, multiplier, maxDelay, retries, expectedDelay
70+
// delay, multiplier, maxDelay, previousRetries, expectedDelay
7171
yield [1000, 1, 5000, 0, 1000];
7272
yield [1000, 1, 5000, 1, 1000];
7373
yield [1000, 1, 5000, 2, 1000];
@@ -90,13 +90,16 @@ public static function provideDelay(): iterable
9090
yield [0, 2, 10000, 1, 0];
9191
}
9292

93-
public function testJitter()
93+
/**
94+
* @dataProvider provideJitter
95+
*/
96+
public function testJitter(float $multiplier, int $previousRetries)
9497
{
95-
$strategy = new GenericRetryStrategy([], 1000, 1, 0, 1);
98+
$strategy = new GenericRetryStrategy([], 1000, $multiplier, 0, 1);
9699
$min = 2000;
97100
$max = 0;
98101
for ($i = 0; $i < 50; ++$i) {
99-
$delay = $strategy->getDelay($this->getContext(0, 'GET', 'http://example.com/', 200), null, null);
102+
$delay = $strategy->getDelay($this->getContext($previousRetries, 'GET', 'http://example.com/', 200), null, null);
100103
$min = min($min, $delay);
101104
$max = max($max, $delay);
102105
}
@@ -105,6 +108,13 @@ public function testJitter()
105108
$this->assertLessThanOrEqual(1000, $min);
106109
}
107110

111+
public static function provideJitter(): iterable
112+
{
113+
// multiplier, previousRetries
114+
yield [1, 0];
115+
yield [1.1, 2];
116+
}
117+
108118
private function getContext($retryCount, $method, $url, $statusCode): AsyncContext
109119
{
110120
$passthru = null;

0 commit comments

Comments
 (0)