8000 Merge branch '5.4' into 6.3 · Romanavr/symfony@80ab630 · GitHub
[go: up one dir, main page]

Skip to content

Commit 80ab630

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: [Validator] Add missing Spanish (es) translations symfony#51956 Add missing dutch translations [WebProfilerBundle] Fix markup to make link to profiler appear on errored WDT [Translation][Validator] Add missing translations for Russian (104 - 109) [Translation][Validator] Add missing translations for Japanese (104 - 109) [Translation] remove blank line [Translation][Validator] Add missing translations for pt_BR (104-109) [Validator] Add missing Persian(fa) translations [PhpUnitBridge] Fix typo Add keyword `dev` to leverage composer hint [RateLimiter] TokenBucket policy fix for adding tokens with a predefined frequency
2 parents 7a6f6df + f74034a commit 80ab630

File tree

12 files changed

+197
-12
lines changed

12 files changed

+197
-12
lines changed

src/Symfony/Bridge/PhpUnit/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "symfony/phpunit-bridge",
33
"type": "symfony-bridge",
44
"description": "Provides utilities for PHPUnit, especially user deprecation notices management",
5-
"keywords": [],
5+
"keywords": ["dev"],
66
"homepage": "https://symfony.com",
77
"license": "MIT",
88
"authors": [

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
636636
sfwdt.innerHTML = '\
637637
<div class="sf-toolbarreset notranslate">\
638638
<div class="sf-toolbar-icon"><svg width="26" height="28" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 26 28" enable-background="new 0 0 26 28" xml:space="preserve"><path fill="#FFFFFF" d="M13 0C5.8 0 0 5.8 0 13c0 7.2 5.8 13 13 13c7.2 0 13-5.8 13-13C26 5.8 20.2 0 13 0z M20 7.5 c-0.6 0-1-0.3-1-0.9c0-0.2 0-0.4 0.2-0.6c0.1-0.3 0.2-0.3 0.2-0.4c0-0.3-0.5-0.4-0.7-0.4c-2 0.1-2.5 2.7-2.9 4.8l-0.2 1.1 c1.1 0.2 1.9 0 2.4-0.3c0.6-0.4-0.2-0.8-0.1-1.3C18 9.2 18.4 9 18.7 8.9c0.5 0 0.8 0.5 0.8 1c0 0.8-1.1 2-3.3 1.9 c-0.3 0-0.5 0-0.7-0.1L15 14.1c-0.4 1.7-0.9 4.1-2.6 6.2c-1.5 1.8-3.1 2.1-3.8 2.1c-1.3 0-2.1-0.6-2.2-1.6c0-0.9 0.8-1.4 1.3-1.4 c0.7 0 1.2 0.5 1.2 1.1c0 0.5-0.2 0.6-0.4 0.7c-0.1 0.1-0.3 0.2-0.3 0.4c0 0.1 0.1 0.3 0.4 0.3c0.5 0 0.9-0.3 1.2-0.5 c1.3-1 1.7-2.9 2.4-6.2l0.1-0.8c0.2-1.1 0.5-2.3 0.8-3.5c-0.9-0.7-1.4-1.5-2.6-1.8c-0.8-0.2-1.3 0-1.7 0.4C8.4 10 8.6 10.7 9 11.1 l0.7 0.7c0.8 0.9 1.3 1.7 1.1 2.7c-0.3 1.6-2.1 2.8-4.3 2.1c-1.9-0.6-2.2-1.9-2-2.7c0.2-0.6 0.7-0.8 1.2-0.6 c0.5 0.2 0.7 0.8 0.6 1.3c0 0.1 0 0.1-0.1 0.3C6 15 5.9 15.2 5.9 15.3c-0.1 0.4 0.4 0.7 0.8 0.8c0.8 0.3 1.7-0.2 1.9-0.9 c0.2-0.6-0.2-1.1-0.4-1.2l-0.8-0.9c-0.4-0.4-1.2-1.5-0.8-2.8c0.2-0.5 0.5-1 0.9-1.4c1-0.7 2-0.8 3-0.6c1.3 0.4 1.9 1.2 2.8 1.9 c0.5-1.3 1.1-2.6 2-3.8c0.9-1 2-1.7 3.3-1.8C20 4.8 21 5.4 21 6.3C21 6.7 20.8 7.5 20 7.5z"/></svg></div>\
639-
An error occurred while loading the web debug toolbar. <a href="{{ url("_profiler_home")|escape('js') }}' + newToken + '>Open the web profiler.</a>\
639+
An error occurred while loading the web debug toolbar. <a href="{{ url("_profiler_home")|escape('js') }}' + newToken + '">Open the web profiler.</a>\
640640
</div>\
641641
';
642642
sfwdt.setAttribute('class', 'sf-toolbar sf-error-toolbar');

src/Symfony/Component/RateLimiter/Policy/Rate.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ public function calculateNewTokensDuringInterval(float $duration): int
9999
return $cycles * $this->refillAmount;
100100
}
101101

102+
/**
103+
* Calculates total amount in seconds of refill intervals during $duration (for maintain strict refill frequency).
104+
*
105+
* @param float $duration interval in seconds
106+
*/
107+
public function calculateRefillInterval(float $duration): int
108+
{
109+
$cycleTime = TimeUtil::dateIntervalToSeconds($this->refillTime);
110+
111+
return floor($duration / $cycleTime) * $cycleTime;
112+
}
113+
102114
public function __toString(): string
103115
{
104116
return $this->refillTime->format('P%yY%mM%dDT%HH%iM%sS').'-'.$this->refillAmount;

src/Symfony/Component/RateLimiter/Policy/TokenBucket.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ public function setTokens(int $tokens): void
6767
public function getAvailableTokens(float $now): int
6868
{
6969
$elapsed = max(0, $now - $this->timer);
70+
$newTokens = $this->rate->calculateNewTokensDuringInterval($elapsed);
7071

71-
return min($this->burstSize, $this->tokens + $this->rate->calculateNewTokensDuringInterval($elapsed));
72+
if ($newTokens > 0) {
73+
$this->timer += $this->rate->calculateRefillInterval($elapsed);
74+
}
75+
76+
return min($this->burstSize, $this->tokens + $newTokens);
7277
}
7378

7479
public function getExpirationTime(): int

src/Symfony/Component/RateLimiter/Policy/TokenBucketLimiter.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public function reserve(int $tokens = 1, float $maxTime = null): Reservation
7070
if ($availableTokens >= max(1, $tokens)) {
7171
// tokens are now available, update bucket
7272
$bucket->setTokens($availableTokens - $tokens);
73-
$bucket->setTimer($now);
7473

7574
$reservation = new Reservation($now, new RateLimit($bucket->getAvailableTokens($now), \DateTimeImmutable::createFromFormat('U', floor($now)), true, $this->maxBurst));
7675
} else {
@@ -87,7 +86,6 @@ public function reserve(int $tokens = 1, float $maxTime = null): Reservation
8786
// at $now + $waitDuration all tokens will be reserved for this process,
8887
// so no tokens are left for other processes.
8988
$bucket->setTokens($availableTokens - $tokens);
90-
$bucket->setTimer($now);
9189

9290
$reservation = new Reservation($now + $waitDuration, new RateLimit(0, \DateTimeImmutable::createFromFormat('U', floor($now + $waitDuration)), false, $this->maxBurst));
9391
}

src/Symfony/Component/RateLimiter/Tests/Policy/TokenBucketLimiterTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,32 @@ public function testPeekConsume()
141141
}
142142
}
143143

144+
public function testBucketRefilledWithStrictFrequency()
145+
{
146+
$limiter = $this->createLimiter(1000, new Rate(\DateInterval::createFromDateString('15 seconds'), 100));
147+
$rateLimit = $limiter->consume(300);
148+
149+
$this->assertTrue($rateLimit->isAccepted());
150+
$this->assertEquals(700, $rateLimit->getRemainingTokens());
151+
152+
$expected = 699;
153+
154+
for ($i = 1; $i <= 20; ++$i) {
155+
$rateLimit = $limiter->consume();
156+
$this->assertTrue($rateLimit->isAccepted());
157+
$this->assertEquals($expected, $rateLimit->getRemainingTokens());
158+
159+
sleep(4);
160+
--$expected;
161+
162+
if (\in_array($i, [4, 8, 12], true)) {
163+
$expected += 100;
164+
} elseif (\in_array($i, [15, 19], true)) {
165+
$expected = 999;
166+
}
167+
}
168+
}
169+
144170
private function createLimiter($initialTokens = 10, Rate $rate = null)
145171
{
146172
return new TokenBucketLimiter('test', $initialTokens, $rate ?? Rate::perSecond(10), $this->storage);

src/Symfony/Component/Validator/Resources/translations/validators.es.xlf

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
</trans-unit>
4141
<trans-unit id="10">
4242
<source>This field is missing.</source>
43-
<target>Este campo está desaparecido.</target>
43+
<target>Este campo falta.</target>
4444
</trans-unit>
4545
<trans-unit id="11">
4646
<source>This value is not a valid date.</source>
4747
<target>Este valor no es una fecha válida.</target>
4848
</trans-unit>
4949
<trans-unit id="12">
5050
<source>This value is not a valid datetime.</source>
51-
<target>Este valor no es una fecha y hora válidas.</target>
51+
<target>Este valor no es una fecha y hora válida.</target>
5252
</trans-unit>
5353
<trans-unit id="13">
5454
<source>This value is not a valid email address.</source>
@@ -184,11 +184,11 @@
184184
</trans-unit>
185185
<trans-unit id="49">
186186
<source>The file was only partially uploaded.</source>
187-
<target>El archivo fue sólo subido parcialmente.</target>
187+
<target>El archivo se cargó solo parcialmente.</target>
188188
</trans-unit>
189189
<trans-unit id="50">
190190
<source>No file was uploaded.</source>
191-
<target>Ningún archivo fue subido.</target>
191+
<target>No se subió ningún archivo.</target>
192192
</trans-unit>
193193
<trans-unit id="51">
194194
<source>No temporary folder was configured in php.ini.</source>
@@ -200,7 +200,7 @@
200200
</trans-unit>
201201
<trans-unit id="53">
202202
<source>A PHP extension caused the upload to fail.</source>
203-
<target>Una extensión de PHP hizo que la subida fallara.</target>
203+
<target>Una extensión de PHP provocó que la carga fallara.</target>
204204
</trans-unit>
205205
<trans-unit id="54">
206206
<source>This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.</source>
@@ -300,7 +300,7 @@
300300
</trans-unit>
301301
<trans-unit id="78">
302302
<source>An empty file is not allowed.</source>
303-
<target>No está permitido un archivo vacío.</target>
303+
<target>No se permite un archivo vacío.</target>
304304
</trans-unit>
305305
<trans-unit id="79">
306306
<source>The host could not be resolved.</source>
@@ -360,7 +360,7 @@
360360
</trans-unit>
361361
<trans-unit id="93">
362362
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363-
<target>Esta contraseña no se puede utilizar porque está incluida en un listado de contraseñas públicas obtenido gracias a fallos de seguridad de otros sitios y aplicaciones. Por favor utilice otra contraseña.</target>
363+
<target>Esta contraseña no se puede utilizar porque está incluida en un listado de contraseñas públicas obtenido gracias a fallos de seguridad de otros sitios y aplicaciones. Por favor, utilice otra contraseña.</target>
364364
</trans-unit>
365365
<trans-unit id="94">
366366
<source>This value should be between {{ min }} and {{ max }}.</source>
@@ -402,6 +402,30 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>El valor de la máscara de red debería estar entre {{ min }} y {{ max }}.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>El nombre del archivo es demasido largo. Debe tener {{ filename_max_length }} carácter o menos.|El nombre del archivo es demasido largo. Debe tener {{ filename_max_length }} caracteres o menos.</target>
408+
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>La seguridad de la contraseña es demasiado baja. Por favor, utilice una contraseña más segura.</target>
412+
</trans-unit>
413+
<trans-unit id="106">
414+
<source>This value contains characters that are not allowed by the current restriction-level.</source>
415+
<target>Este valor contiene caracteres que no están permitidos según el nivel de restricción actual.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>No se permite el uso de caracteres invisibles.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>No está permitido mezclar números de diferentes scripts.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>No está permitido el uso de caracteres superpuestos ocultos.</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.fa.xlf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,30 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>مقدار ماسک شبکه (NetMask) باید بین {{ min }} و {{ max }} باشد.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>نام فایل طولانی است. نام فایل باید {{ filename_max_length }} کاراکتر یا کمتر باشد.|نام فایل طولانی است. نام فایل باید {{ filename_max_length }} کاراکتر یا کمتر باشد.</target>
408+
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>رمز عبور ضعیف است. لطفا از رمز عبور قوی‌تری استفاده کنید.</target>
412+
</trans-unit>
413+
<trans-unit id="106">
414+
<source>This value contains characters that are not allowed by the current restriction-level.</source>
415+
<target>این مقدار حاوی کاراکترهایی است که در سطح محدودیت فعلی مجاز نیستند.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>استفاده از کاراکترهای نامرئی مجاز نمی‌باشد.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>مخلوط کردن اعداد از اسکریپت های مختلف مجاز نیست.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>استفاده از کاراکترهای همپوشانی پنهان (hidden overlay characters) مجاز نیست.</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,30 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>ネットマスクの値は、{{ min }}から{{ max }}の間にある必要があります。</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>ファイル名が長すぎます。ファイル名の長さは{{ filename_max_length }}文字以下でなければなりません。</target>
408+
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>パスワードの強度が弱すぎます。より強いパスワードを使用してください。</target>
412+
</trans-unit>
413+
<trans-unit id="106">
414+
<source>This value contains characters that are not allowed by the current restriction-level.</source>
415+
<target>この値は現在の制限レベルで許可されていない文字を含んでいます。</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>不可視文字は使用できません。</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>異なる種類の数字を使うことはできません。</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>隠れたオーバレイ文字は使用できません。</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,30 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>De waarde van de netmask moet zich tussen {{ min }} en {{ max }} bevinden.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>De bestandsnaam is te lang. Het moet {{ filename_max_length }} karakter of minder zijn.</target>
408+
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>De wachtwoordsterkte is te laag. Gebruik alstublieft een sterker wachtwoord.</target>
412+
</trans-unit>
413+
<trans-unit id="106">
414+
<source>This value contains characters that are not allowed by the current restriction-level.</source>
415+
<target>Deze waarde bevat tekens die niet zijn toegestaan volgens het huidige beperkingsniveau.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>Het gebruik van onzichtbare tekens is niet toegestaan.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
64F1 <source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>Het mengen van cijfers uit verschillende schriften is niet toegestaan.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>Het gebruik van verborgen overlay-tekens is niet toegestaan.</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

0 commit comments

Comments
 (0)
0