8000 Merge branch '4.3' into 4.4 · symfony/symfony@47f7cdc · GitHub
[go: up one dir, main page]

Skip to content

Commit 47f7cdc

Browse files
Merge branch '4.3' into 4.4
* 4.3: Fixed #35084 Add missing use statement [HttpClient] fix scheduling pending NativeResponse do not overwrite variable value [Profiler] wording Use spaces correctly to display options in DebugCommand X-Accel Nginx URL updated ticket-30197 [Validator] Add the missing translations for the Chinese (Taiwan) ("zh_TW") locale Fixed test added in #35022 Use locale_parse for computing fallback locales [Console] Fix filtering out identical alternatives when there is a command loader
2 parents 63dd7a3 + f3d8fd2 commit 47f7cdc

File tree

15 files changed

+181
-58
lines changed

15 files changed

+181
-58
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'no_token' : {
55
status: 'error',
66
title: (token|default('') == 'latest') ? 'There are no profiles' : 'Token not found',
7-
message: (token|default('') == 'latest') ? 'No profiles found in the database.' : 'Token "' ~ token|default('') ~ '" was not found in the database.'
7+
message: (token|default('') == 'latest') ? 'No profiles found.' : 'Token "' ~ token|default('') ~ '" not found.'
88
}
99
} %}
1010

src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function process(ContainerBuilder $container)
5555
}
5656
$seed .= '.'.$container->getParameter('kernel.container_class');
5757

58-
$pools = [];
58+
$allPools = [];
5959
$clearers = [];
6060
$attributes = [
6161
'provider',
@@ -163,15 +163,15 @@ public function process(ContainerBuilder $container)
163163
$clearers[$clearer][$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
164164
}
165165

166-
$pools[$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
166+
$allPools[$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
167167
}
168168

169169
$notAliasedCacheClearerId = $this->cacheClearerId;
170170
while ($container->hasAlias($this->cacheClearerId)) {
171171
$this->cacheClearerId = (string) $container->getAlias($this->cacheClearerId);
172172
}
173173
if ($container->hasDefinition($this->cacheClearerId)) {
174-
$clearers[$notAliasedCacheClearerId] = $pools;
174+
$clearers[$notAliasedCacheClearerId] = $allPools;
175175
}
176176

177177
foreach ($clearers as $id => $pools) {
@@ -189,7 +189,7 @@ public function process(ContainerBuilder $container)
189189
}
190190

191191
if ($container->hasDefinition('console.command.cache_pool_list')) {
192-
$container->getDefinition('console.command.cache_pool_list')->replaceArgument(0, array_keys($pools));
192+
$container->getDefinition('console.command.cache_pool_list')->replaceArgument(0, array_keys($allPools));
193193
}
194194
}
195195

src/Symfony/Component/Console/Application.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,13 @@ public function find($name)
673673
// filter out aliases for commands which are already on the list
674674
if (\count($commands) > 1) {
675675
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
676-
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
677-
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
676+
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
677+
if (!$commandList[$nameOrAlias] instanceof Command) {
678+
$commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
679+
}
680+
681+
$commandName = $commandList[$nameOrAlias]->getName();
682+
678683
$aliases[$nameOrAlias] = $commandName;
679684

680685
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
@@ -689,10 +694,6 @@ public function find($name)
689694
$maxLen = max(Helper::strlen($abbrev), $maxLen);
690695
}
691696
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
692-
if (!$commandList[$cmd] instanceof Command) {
693-
$commandList[$cmd] = $this->commandLoader->get($cmd);
694-
}
695-
696697
if ($commandList[$cmd]->isHidden()) {
697698
unset($commands[array_search($cmd, $commands)]);
698699

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ public function testFindAlternativeCommandsWithAnAlias()
626626
$fooCommand->setAliases(['foo2']);
627627

628628
$application = new Application();
629+
$application->setCommandLoader(new FactoryCommandLoader([
630+
'foo3' => static function () use ($fooCommand) { return $fooCommand; },
631+
]));
629632
$application->add($fooCommand);
630633

631634
$result = $application->find('foo');

src/Symfony/Component/Dotenv/Tests/DotenvTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,13 @@ public function testGetVariablesValueFromGetenv()
448448
putenv('Foo=Bar');
449449

450450
$dotenv = new Dotenv(true);
451-
$values = $dotenv->parse('Foo=${Foo}');
452-
$this->assertSame('Bar', $values['Foo']);
453451

454-
putenv('Foo');
452+
try {
453+
$values = $dotenv->parse('Foo=${Foo}');
454+
$this->assertSame('Bar', $values['Foo']);
455+
} finally {
456+
putenv('Foo');
457+
}
455458
}
456459

457460
/**

src/Symfony/Component/HttpClient/Internal/NativeClientState.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\HttpClient\Internal;
1313

14-
use Symfony\Component\HttpClient\Response\NativeResponse;
15-
1614
/**
1715
* Internal representation of the native client's state.
1816
*
@@ -24,8 +22,6 @@ final class NativeClientState extends ClientState
2422
{
2523
/** @var int */
2624
public $id;
27-
/** @var NativeResponse[] */
28-
public $pendingResponses = [];
2925
/** @var int */
3026
public $maxHostConnections = PHP_INT_MAX;
3127
/** @var int */

src/Symfony/Component/HttpClient/Response/NativeResponse.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,7 @@ private static function schedule(self $response, array &$runningResponses): void
230230
$runningResponses[$i] = [$response->multi, []];
231231
}
232232

233-
if (null === $response->remaining) {
234-
$response->multi->pendingResponses[] = $response;
235-
} else {
236-
$runningResponses[$i][1][$response->id] = $response;
237-
}
233+
$runningResponses[$i][1][$response->id] = $response;
238234

239235
if (null === $response->buffer) {
240236
// Response already completed
@@ -336,25 +332,30 @@ private static function perform(NativeClientState $multi, array &$responses = nu
336332
return;
337333
}
338334

339-
if ($multi->pendingResponses && \count($multi->handles) < $multi->maxHostConnections) {
340-
// Open the next pending request - this is a blocking operation so we do only one of them
341-
/** @var self $response */
342-
$response = array_shift($multi->pendingResponses);
343-
$response->open();
344-
$responses[$response->id] = $response;
345-
$multi->sleep = false;
346-
self::perform($response->multi);
347-
348-
if (null !== $response->handle) {
349-
$multi->handles[] = $response->handle;
335+
// Create empty activity lists to tell ResponseTrait::stream() we still have pending requests
336+
foreach ($responses as $i => $response) {
337+
if (null === $response->remaining && null !== $response->buffer) {
338+
$multi->handlesActivity[$i] = [];
350339
}
351340
}
352341

353-
if ($multi->pendingResponses) {
354-
// Create empty activity list to tell ResponseTrait::stream() we still have pending requests
355-
$response = $multi->pendingResponses[0];
356-
$responses[$response->id] = $response;
357-
$multi->handlesActivity[$response->id] = [];
342+
if (\count($multi->handles) >= $multi->maxHostConnections) {
343+
return;
344+
}
345+
346+
// Open the next pending request - this is a blocking operation so we do only one of them
347+
foreach ($responses as $i => $response) {
348+
if (null === $response->remaining && null !== $response->buffer) {
349+
$response->open();
350+
$multi->sleep = false;
351+
self::perform($multi);
352+
353+
if (null !== $response->handle) {
354+
$multi->handles[] = $response->handle;
355+
}
356+
357+
break;
358+
}
358359
}
359360
}
360361

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function prepare(Request $request)
217217
}
218218
if ('x-accel-redirect' === strtolower($type)) {
219219
// Do X-Accel-Mapping substitutions.
220-
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
220+
// @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect
221221
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
222222
foreach ($parts as $part) {
223223
list($pathPrefix, $location) = $part;

src/Symfony/Component/Messenger/Command/DebugCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ private function formatConditions(array $options): string
108108

109109
$optionsMapping = [];
110110
foreach ($options as $key => $value) {
111-
$optionsMapping[] = ' '.$key.'='.$value;
111+
$optionsMapping[] = $key.'='.$value;
112112
}
113113

114-
return ' (when'.implode(', ', $optionsMapping).')';
114+
return ' (when '.implode(', ', $optionsMapping).')';
115115
}
116116
}

src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testOutput()
4040
{
4141
$command = new DebugCommand([
4242
'command_bus' => [
43-
DummyCommand::class => [[DummyCommandHandler::class, []]],
43+
DummyCommand::class => [[DummyCommandHandler::class, ['option1' => '1', 'option2' => '2']]],
4444
MultipleBusesMessage::class => [[MultipleBusesMessageHandler::class, []]],
4545
],
4646
'query_bus' => [
@@ -62,12 +62,12 @@ public function testOutput()
6262
6363
The following messages can be dispatched:
6464
65-
---------------------------------------------------------------------------------------
66-
Symfony\Component\Messenger\Tests\Fixtures\DummyCommand
67-
handled by Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler
68-
Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessage
69-
handled by Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler
70-
---------------------------------------------------------------------------------------
65+
-----------------------------------------------------------------------------------------------------------
66+
Symfony\Component\Messenger\Tests\Fixtures\DummyCommand
67+
handled by Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler (when option1=1, option2=2)
68+
Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessage
69+
handled by Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler
70+
-----------------------------------------------------------------------------------------------------------
7171
7272
query_bus
7373
---------

src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
1717
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
1818
use Symfony\Component\Translation\DataCollectorTranslator;
19+
use Symfony\Component\VarDumper\Cloner\Data;
1920

2021
/**
2122
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>

src/Symfony/Component/Translation/Tests/TranslatorTest.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,38 @@ public function testTransWithIcuRootFallbackLocale()
305305
$this->assertSame('bar', $translator->trans('bar'));
306306
}
307307

308-
public function testTransWithFallbackLocaleBis()
308+
/**
309+
* @dataProvider getFallbackLocales
310+
*/
311+
public function testTransWithFallbackLocaleBis($expectedLocale, $locale)
309312
{
310-
$translator = new Translator('en_US');
313+
$translator = new Translator($locale);
311314
$translator->addLoader('array', new ArrayLoader());
312-
$translator->addResource('array', ['foo' => 'foofoo'], 'en_US');
313-
$translator->addResource('array', ['bar' => 'foobar'], 'en');
315+
$translator->addResource('array', ['foo' => 'foofoo'], $locale);
316+
$translator->addResource('array', ['bar' => 'foobar'], $expectedLocale);
314317
$this->assertEquals('foobar', $translator->trans('bar'));
315318
}
316319

320+
public function getFallbackLocales()
321+
{
322+
$locales = [
323+
['en', 'en_US'],
324+
['en', 'en-US'],
325+
['sl_Latn_IT', 'sl_Latn_IT_nedis'],
326+
['sl_Latn', 'sl_Latn_IT'],
327+
];
328+
329+
if (\function_exists('locale_parse')) {
330+
$locales[] = ['sl_Latn_IT', 'sl-Latn-IT-nedis'];
331+
$locales[] = ['sl_Latn', 'sl-Latn-IT'];
332+
} else {
333+
$locales[] = ['sl-Latn-IT', 'sl-Latn-IT-nedis'];
334+
$locales[] = ['sl-Latn', 'sl-Latn-IT'];
335+
}
336+
337+
return $locales;
338+
}
339+
317340
public function testTransWithFallbackLocaleTer()
318341
{
319342
$translator = new Translator('fr_FR');

src/Symfony/Component/Translation/Translator.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,17 @@ protected function computeFallbackLocales($locale)
471471
while ($locale) {
472472
$parent = $parentLocales[$locale] ?? null;
473473

474-
if (!$parent && false !== strrchr($locale, '_')) {
475-
$locale = substr($locale, 0, -\strlen(strrchr($locale, '_')));
476-
} elseif ('root' !== $parent) {
477-
$locale = $parent;
474+
if ($parent) {
475+
$locale = 'root' !== $parent ? $parent : null;
476+
} elseif (\function_exists('locale_parse')) {
477+
$localeSubTags = locale_parse($locale);
478+
$locale = null;
479+
if (1 < \count($localeSubTags)) {
480+
array_pop($localeSubTags);
481+
$locale = locale_compose($localeSubTags) ?: null;
482+
}
483+
} elseif ($i = strrpos($locale, '_') ?: strrpos($locale, '-')) {
484+
$locale = substr($locale, 0, $i);
478485
} else {
479486
$locale = null;
480487
}

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

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,94 @@
278278
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
279279
<target>該值不應與 {{ compared_value_type }} {{ compared_value }} 相同。</target>
280280
</trans-unit>
281+
<trans-unit id="73">
282+
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
283+
<target>圖像格式過大 ({{ ratio }})。 最大允許尺寸 {{ max_ratio }}。</target>
284+
</trans-unit>
285+
<trans-unit id="74">
286+
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
287+
<target>圖像格式過小 ({{ ratio }})。最小尺寸 {{ min_ratio }}。</target>
288+
</trans-unit>
289+
<trans-unit id="75">
290+
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
291+
<target>方形圖像 ({{ width }}x{{ height }}px)。不接受方形圖像。</target>
292+
</trans-unit>
293+
<trans-unit id="76">
294+
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
295+
<target>紀念冊布局圖像 ({{ width }}x{{ height }}px)。 不接受紀念冊布局圖像。</target>
296+
</trans-unit>
297+
<trans-unit id="77">
298+
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
299+
<target>書籍布局圖像 ({{ width }}x{{ height }}px)。不接受圖像書籍布局。</target>
300+
</trans-unit>
301+
<trans-unit id="78">
302+
<source>An empty file is not allowed.</source>
303+
<target>不接受空白文件。</target>
304+
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>未找到服務器。</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>該數值不符合預期 {{ charset }} 符號編碼。</target>
312+
</trans-unit>
313+
<trans-unit id="81">
314+
<source>This is not a valid Business Identifier Code (BIC).</source>
315+
<target>無效企業識別碼 (BIC)。</target>
316+
</trans-unit>
317+
<trans-unit id="82">
318+
<source>Error.</source>
319+
<target>錯誤。</target>
320+
</trans-unit>
321+
<trans-unit id="83">
322+
<source>This is not a valid UUID.</source>
323+
<target>無效的通用唯壹標識符 (UUID)。</target>
324+
</trans-unit>
325+
<trans-unit id="84">
326+
<source>This value should be a multiple of {{ compared_value }}.</source>
327+
<target>該值必須是倍數 {{ compared_value }}。</target>
328+
</trans-unit>
329+
<trans-unit id="85">
330+
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
331+
<target>該企業識別碼 (BIC) 與銀行賬戶國際編號不壹致 (IBAN) {{ iban }}。</target>
332+
</trans-unit>
333+
<trans-unit id="86">
334+
<source>This value should be valid JSON.</source>
335+
<target>該數值必須序列化為JSON格式。</target>
336+
</trans-unit>
337+
<trans-unit id="87">
338+
<source>This collection should contain only unique elements.</source>
339+
<target>該集合應僅包含唯壹元素。</target>
340+
</trans-unit>
341+
<trans-unit id="88">
342+
<source>This value should be positive.</source>
343+
<target>數值應為正數。</target>
344+
</trans-unit>
345+
<trans-unit id="89">
346+
<source>This value should be either positive or zero.</source>
347+
<target>數值應或未正數,或為零。</target>
348+
</trans-unit>
349+
<trans-unit id="90">
350+
<source>This value should be negative.</source>
351+
<target>數值應為負數。</target>
352+
</trans-unit>
353+
<trans-unit id="91">
354+
<source>This value should be either negative or zero.</source>
355+
<target>數值應或未負數,或為零。</target>
356+
</trans-unit>
357+
<trans-unit id="92">
358+
<source>This value is not a valid timezone.</source>
359+
<target>無效時區。</target>
360+
</trans-unit>
361+
<trans-unit id="93">
362+
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363+
<target>依據您的密碼,發生數據泄露,請勿使用改密碼。請更換密碼。</target>
364+
</trans-unit>
365+
<trans-unit id="94">
366+
<source>This value should be between {{ min }} and {{ max }}.</source>
367+
<target>該數值應在 {{ min }} 和 {{ max }} 之間。</target>
368+
</trans-unit>
281369
</body>
282370
</file>
283371
</xliff>

0 commit comments

Comments
 (0)
0