From 589e93e3b70f3c4ac6f1fc2c81f5349e676b3e0c Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Mon, 23 Dec 2019 21:21:28 +0100 Subject: [PATCH 01/11] [Console] Fix filtering out identical alternatives when there is a command loader --- src/Symfony/Component/Console/Application.php | 13 +++++++------ .../Component/Console/Tests/ApplicationTest.php | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index d181e41e80..1463967ffa 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -645,8 +645,13 @@ class Application // filter out aliases for commands which are already on the list if (\count($commands) > 1) { $commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands; - $commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) { - $commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias; + $commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) { + if (!$commandList[$nameOrAlias] instanceof Command) { + $commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias); + } + + $commandName = $commandList[$nameOrAlias]->getName(); + $aliases[$nameOrAlias] = $commandName; return $commandName === $nameOrAlias || !\in_array($commandName, $commands); @@ -662,10 +667,6 @@ class Application $maxLen = max(Helper::strlen($abbrev), $maxLen); } $abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen) { - if (!$commandList[$cmd] instanceof Command) { - $commandList[$cmd] = $this->commandLoader->get($cmd); - } - if ($commandList[$cmd]->isHidden()) { return false; } diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 30c0688ac7..559c42599f 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -568,6 +568,9 @@ class ApplicationTest extends TestCase $fooCommand->setAliases(['foo2']); $application = new Application(); + $application->setCommandLoader(new FactoryCommandLoader([ + 'foo3' => static function () use ($fooCommand) { return $fooCommand; }, + ])); $application->add($fooCommand); $result = $application->find('foo'); From 3657c0e664bfb1a62f9fea9a898406909a1e130b Mon Sep 17 00:00:00 2001 From: Alan Poulain Date: Tue, 24 Dec 2019 19:50:33 +0100 Subject: [PATCH 02/11] Use locale_parse for computing fallback locales --- .../Translation/Tests/TranslatorTest.php | 31 ++++++++++++++++--- .../Component/Translation/Translator.php | 13 +++++++- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index 77af7de33e..68122b2915 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -234,15 +234,38 @@ class TranslatorTest extends TestCase $this->assertEquals('bar', $translator->trans('foo', [], 'resources')); } - public function testTransWithFallbackLocaleBis() + /** + * @dataProvider getFallbackLocales + */ + public function testTransWithFallbackLocaleBis($expectedLocale, $locale) { - $translator = new Translator('en_US'); + $translator = new Translator($locale); $translator->addLoader('array', new ArrayLoader()); - $translator->addResource('array', ['foo' => 'foofoo'], 'en_US'); - $translator->addResource('array', ['bar' => 'foobar'], 'en'); + $translator->addResource('array', ['foo' => 'foofoo'], $locale); + $translator->addResource('array', ['bar' => 'foobar'], $expectedLocale); $this->assertEquals('foobar', $translator->trans('bar')); } + public function getFallbackLocales() + { + $locales = [ + ['en', 'en_US'], + ['en', 'en-US'], + ['sl_Latn_IT', 'sl_Latn_IT_nedis'], + ['sl_Latn', 'sl_Latn_IT'], + ]; + + if (\function_exists('locale_parse')) { + $locales[] = ['sl_Latn_IT', 'sl-Latn-IT-nedis']; + $locales[] = ['sl_Latn', 'sl-Latn-IT']; + } else { + $locales[] = ['sl-Latn-IT', 'sl-Latn-IT-nedis']; + $locales[] = ['sl-Latn', 'sl-Latn-IT']; + } + + return $locales; + } + public function testTransWithFallbackLocaleTer() { $translator = new Translator('fr_FR'); diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index e72d20a86f..1bda62d1b1 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -412,8 +412,19 @@ EOF $locales[] = $fallback; } - if (false !== strrchr($locale, '_')) { + if (\function_exists('locale_parse')) { + $localeSubTags = locale_parse($locale); + if (1 < \count($localeSubTags)) { + array_pop($localeSubTags); + $fallback = locale_compose($localeSubTags); + if (false !== $fallback) { + array_unshift($locales, $fallback); + } + } + } elseif (false !== strrchr($locale, '_')) { array_unshift($locales, substr($locale, 0, -\strlen(strrchr($locale, '_')))); + } elseif (false !== strrchr($locale, '-')) { + array_unshift($locales, substr($locale, 0, -\strlen(strrchr($locale, '-')))); } return array_unique($locales); From 6eeec7c270ed07c04f7323321816e38364cc3ee5 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Thu, 19 Dec 2019 18:52:42 +0000 Subject: [PATCH 03/11] Fixed test added in #35022 --- src/Symfony/Component/Dotenv/Tests/DotenvTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php index 965f368643..43607d3555 100644 --- a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php +++ b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php @@ -320,9 +320,12 @@ class DotenvTest extends TestCase putenv('Foo=Bar'); $dotenv = new Dotenv(true); - $values = $dotenv->parse('Foo=${Foo}'); - $this->assertSame('Bar', $values['Foo']); - putenv('Foo'); + try { + $values = $dotenv->parse('Foo=${Foo}'); + $this->assertSame('Bar', $values['Foo']); + } finally { + putenv('Foo'); + } } } From 36f07b7e09721efbdf174d6e46478833c7719ca5 Mon Sep 17 00:00:00 2001 From: Islam93 Date: Fri, 20 Dec 2019 15:44:59 +0300 Subject: [PATCH 04/11] ticket-30197 [Validator] Add the missing translations for the Chinese (Taiwan) ("zh_TW") locale --- .../translations/validators.zh_TW.xlf | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf index d9d5f2f622..7cef875f58 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf @@ -278,6 +278,94 @@ This value should not be identical to {{ compared_value_type }} {{ compared_value }}. 該值不應與 {{ compared_value_type }} {{ compared_value }} 相同。 + + The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}. + 圖像格式過大 ({{ ratio }})。 最大允許尺寸 {{ max_ratio }}。 + + + The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}. + 圖像格式過小 ({{ ratio }})。最小尺寸 {{ min_ratio }}。 + + + The image is square ({{ width }}x{{ height }}px). Square images are not allowed. + 方形圖像 ({{ width }}x{{ height }}px)。不接受方形圖像。 + + + The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed. + 紀念冊布局圖像 ({{ width }}x{{ height }}px)。 不接受紀念冊布局圖像。 + + + The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed. + 書籍布局圖像 ({{ width }}x{{ height }}px)。不接受圖像書籍布局。 + + + An empty file is not allowed. + 不接受空白文件。 + + + The host could not be resolved. + 未找到服務器。 + + + This value does not match the expected {{ charset }} charset. + 該數值不符合預期 {{ charset }} 符號編碼。 + + + This is not a valid Business Identifier Code (BIC). + 無效企業識別碼 (BIC)。 + + + Error. + 錯誤。 + + + This is not a valid UUID. + 無效的通用唯壹標識符 (UUID)。 + + + This value should be a multiple of {{ compared_value }}. + 該值必須是倍數 {{ compared_value }}。 + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + 該企業識別碼 (BIC) 與銀行賬戶國際編號不壹致 (IBAN) {{ iban }}。 + + + This value should be valid JSON. + 該數值必須序列化為JSON格式。 + + + This collection should contain only unique elements. + 該集合應僅包含唯壹元素。 + + + This value should be positive. + 數值應為正數。 + + + This value should be either positive or zero. + 數值應或未正數,或為零。 + + + This value should be negative. + 數值應為負數。 + + + This value should be either negative or zero. + 數值應或未負數,或為零。 + + + This value is not a valid timezone. + 無效時區。 + + + This password has been leaked in a data breach, it must not be used. Please use another password. + 依據您的密碼,發生數據泄露,請勿使用改密碼。請更換密碼。 + + + This value should be between {{ min }} and {{ max }}. + 該數值應在 {{ min }} 和 {{ max }} 之間。 + From 4557221597e6def8e417cb1bc4099bcf6da5f01c Mon Sep 17 00:00:00 2001 From: Shaharia Azam Date: Sat, 21 Dec 2019 04:43:02 +0600 Subject: [PATCH 05/11] X-Accel Nginx URL updated Obsolete URL has been updated --- src/Symfony/Component/HttpFoundation/BinaryFileResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index ea7ac84697..c2f66d6952 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -217,7 +217,7 @@ class BinaryFileResponse extends Response } if ('x-accel-redirect' === strtolower($type)) { // Do X-Accel-Mapping substitutions. - // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect + // @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { $mapping = explode('=', $mapping, 2); From 1c92e9e2f14ee97fc1fdeccfddbbc69804c32c40 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Wed, 25 Dec 2019 17:22:15 +0100 Subject: [PATCH 06/11] Use spaces correctly to display options in DebugCommand --- .../Component/Messenger/Command/DebugCommand.php | 4 ++-- .../Messenger/Tests/Command/DebugCommandTest.php | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Messenger/Command/DebugCommand.php b/src/Symfony/Component/Messenger/Command/DebugCommand.php index 2fba6f02f5..08b76d1c19 100644 --- a/src/Symfony/Component/Messenger/Command/DebugCommand.php +++ b/src/Symfony/Component/Messenger/Command/DebugCommand.php @@ -108,9 +108,9 @@ EOF $optionsMapping = []; foreach ($options as $key => $value) { - $optionsMapping[] = ' '.$key.'='.$value; + $optionsMapping[] = $key.'='.$value; } - return ' (when'.implode(', ', $optionsMapping).')'; + return ' (when '.implode(', ', $optionsMapping).')'; } } diff --git a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php index 02812adb47..e637d51dd3 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php @@ -40,7 +40,7 @@ class DebugCommandTest extends TestCase { $command = new DebugCommand([ 'command_bus' => [ - DummyCommand::class => [[DummyCommandHandler::class, []]], + DummyCommand::class => [[DummyCommandHandler::class, ['option1' => '1', 'option2' => '2']]], MultipleBusesMessage::class => [[MultipleBusesMessageHandler::class, []]], ], 'query_bus' => [ @@ -62,12 +62,12 @@ command_bus The following messages can be dispatched: - --------------------------------------------------------------------------------------- - Symfony\Component\Messenger\Tests\Fixtures\DummyCommand - handled by Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler - Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessage - handled by Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler - --------------------------------------------------------------------------------------- + ----------------------------------------------------------------------------------------------------------- + Symfony\Component\Messenger\Tests\Fixtures\DummyCommand + handled by Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler (when option1=1, option2=2) + Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessage + handled by Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler + ----------------------------------------------------------------------------------------------------------- query_bus --------- From e7c9a28a03bdaf0c862335224737bebe3fd19f14 Mon Sep 17 00:00:00 2001 From: noniagriconomie Date: Tue, 17 Dec 2019 19:01:32 +0100 Subject: [PATCH 07/11] [Profiler] wording --- .../WebProfilerBundle/Resources/views/Profiler/info.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig index 0227532e12..43404393ec 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig @@ -4,7 +4,7 @@ 'no_token' : { status: 'error', title: (token|default('') == 'latest') ? 'There are no profiles' : 'Token not found', - message: (token|default('') == 'latest') ? 'No profiles found in the database.' : 'Token "' ~ token|default('') ~ '" was not found in the database.' + message: (token|default('') == 'latest') ? 'No profiles found.' : 'Token "' ~ token|default('') ~ '" not found.' } } %} From e379dbbf219b52779b34acb40a00afc94f758541 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 27 Dec 2019 10:02:48 +0100 Subject: [PATCH 08/11] do not overwrite variable value --- .../Component/Cache/DependencyInjection/CachePoolPass.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php index eef9e75b06..00784b64f5 100644 --- a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php +++ b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php @@ -54,7 +54,7 @@ class CachePoolPass implements CompilerPassInterface } $seed .= '.'.$container->getParameter('kernel.container_class'); - $pools = []; + $allPools = []; $clearers = []; $attributes = [ 'provider', @@ -119,7 +119,7 @@ class CachePoolPass implements CompilerPassInterface $clearers[$clearer][$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE); } - $pools[$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE); + $allPools[$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE); } $notAliasedCacheClearerId = $this->cacheClearerId; @@ -127,7 +127,7 @@ class CachePoolPass implements CompilerPassInterface $this->cacheClearerId = (string) $container->getAlias($this->cacheClearerId); } if ($container->hasDefinition($this->cacheClearerId)) { - $clearers[$notAliasedCacheClearerId] = $pools; + $clearers[$notAliasedCacheClearerId] = $allPools; } foreach ($clearers as $id => $pools) { @@ -145,7 +145,7 @@ class CachePoolPass implements CompilerPassInterface } if ($container->hasDefinition('console.command.cache_pool_list')) { - $container->getDefinition('console.command.cache_pool_list')->replaceArgument(0, array_keys($pools)); + $container->getDefinition('console.command.cache_pool_list')->replaceArgument(0, array_keys($allPools)); } } From a90a6c9c4849a1342ebee66417e1046470b81eaf Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 27 Dec 2019 11:24:52 +0100 Subject: [PATCH 09/11] [HttpClient] fix scheduling pending NativeResponse --- .../HttpClient/Internal/NativeClientState.php | 4 -- .../HttpClient/Response/NativeResponse.php | 43 ++++++++++--------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/HttpClient/Internal/NativeClientState.php b/src/Symfony/Component/HttpClient/Internal/NativeClientState.php index e82ce4c853..6578929dc5 100644 --- a/src/Symfony/Component/HttpClient/Internal/NativeClientState.php +++ b/src/Symfony/Component/HttpClient/Internal/NativeClientState.php @@ -11,8 +11,6 @@ namespace Symfony\Component\HttpClient\Internal; -use Symfony\Component\HttpClient\Response\NativeResponse; - /** * Internal representation of the native client's state. * @@ -24,8 +22,6 @@ final class NativeClientState extends ClientState { /** @var int */ public $id; - /** @var NativeResponse[] */ - public $pendingResponses = []; /** @var int */ public $maxHostConnections = PHP_INT_MAX; /** @var int */ diff --git a/src/Symfony/Component/HttpClient/Response/NativeResponse.php b/src/Symfony/Component/HttpClient/Response/NativeResponse.php index b8af399a94..49e25c51bc 100644 --- a/src/Symfony/Component/HttpClient/Response/NativeResponse.php +++ b/src/Symfony/Component/HttpClient/Response/NativeResponse.php @@ -209,11 +209,7 @@ final class NativeResponse implements ResponseInterface $runningResponses[$i] = [$response->multi, []]; } - if (null === $response->remaining) { - $response->multi->pendingResponses[] = $response; - } else { - $runningResponses[$i][1][$response->id] = $response; - } + $runningResponses[$i][1][$response->id] = $response; if (null === $response->buffer) { // Response already completed @@ -315,25 +311,30 @@ final class NativeResponse implements ResponseInterface return; } - if ($multi->pendingResponses && \count($multi->handles) < $multi->maxHostConnections) { - // Open the next pending request - this is a blocking operation so we do only one of them - /** @var self $response */ - $response = array_shift($multi->pendingResponses); - $response->open(); - $responses[$response->id] = $response; - $multi->sleep = false; - self::perform($response->multi); - - if (null !== $response->handle) { - $multi->handles[] = $response->handle; + // Create empty activity lists to tell ResponseTrait::stream() we still have pending requests + foreach ($responses as $i => $response) { + if (null === $response->remaining && null !== $response->buffer) { + $multi->handlesActivity[$i] = []; } } - if ($multi->pendingResponses) { - // Create empty activity list to tell ResponseTrait::stream() we still have pending requests - $response = $multi->pendingResponses[0]; - $responses[$response->id] = $response; - $multi->handlesActivity[$response->id] = []; + if (\count($multi->handles) >= $multi->maxHostConnections) { + return; + } + + // Open the next pending request - this is a blocking operation so we do only one of them + foreach ($responses as $i => $response) { + if (null === $response->remaining && null !== $response->buffer) { + $response->open(); + $multi->sleep = false; + self::perform($multi); + + if (null !== $response->handle) { + $multi->handles[] = $response->handle; + } + + break; + } } } From 6fd266dba65690eaf4106f33940a4cc811050848 Mon Sep 17 00:00:00 2001 From: Olivier Dolbeau Date: Fri, 27 Dec 2019 12:18:21 +0100 Subject: [PATCH 10/11] Add missing use statement --- .../Translation/DataCollector/TranslationDataCollector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php index fc713463a0..5b96a22f35 100644 --- a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php +++ b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; use Symfony\Component\Translation\DataCollectorTranslator; +use Symfony\Component\VarDumper\Cloner\Data; /** * @author Abdellatif Ait boudad From 340bb145d9cd338a24314781701991a7e3d7c68f Mon Sep 17 00:00:00 2001 From: Dmitriy Derepko Date: Thu, 26 Dec 2019 15:06:00 +0300 Subject: [PATCH 11/11] Fixed #35084 --- .../VarDumper/Dumper/ContextProvider/CliContextProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/VarDumper/Dumper/ContextProvider/CliContextProvider.php b/src/Symfony/Component/VarDumper/Dumper/ContextProvider/CliContextProvider.php index e7f8ccf17f..38f878971c 100644 --- a/src/Symfony/Component/VarDumper/Dumper/ContextProvider/CliContextProvider.php +++ b/src/Symfony/Component/VarDumper/Dumper/ContextProvider/CliContextProvider.php @@ -25,7 +25,7 @@ final class CliContextProvider implements ContextProviderInterface } return [ - 'command_line' => $commandLine = implode(' ', $_SERVER['argv']), + 'command_line' => $commandLine = implode(' ', $_SERVER['argv'] ?? []), 'identifier' => hash('crc32b', $commandLine.$_SERVER['REQUEST_TIME_FLOAT']), ]; }