From 707c5bade0dd7220b6d7e03dd7e27d66840edeb0 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Tue, 11 Feb 2020 11:52:39 +0100 Subject: [PATCH 1/8] [Console] Don't load same-namespace alternatives on exact match found --- src/Symfony/Component/Console/Application.php | 20 ++++++++++++--- .../Console/Tests/ApplicationTest.php | 25 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 1463967ffa..280a34d5c5 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -645,7 +645,15 @@ 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) { + + if (isset($commandList[$name])) { + return $this->get($name); + } + + foreach ($commands as $k => $nameOrAlias) { + if ($nameOrAlias === $name) { + return $this->get($nameOrAlias); + } if (!$commandList[$nameOrAlias] instanceof Command) { $commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias); } @@ -654,8 +662,14 @@ class Application $aliases[$nameOrAlias] = $commandName; - return $commandName === $nameOrAlias || !\in_array($commandName, $commands); - })); + if ($commandName === $nameOrAlias || !\in_array($commandName, $commands)) { + continue; + } + + unset($commands[$k]); + } + + $commands = array_unique($commands); } $exact = \in_array($name, $commands, true) || isset($aliases[$name]); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 559c42599f..8288cfd326 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -1642,6 +1642,31 @@ class ApplicationTest extends TestCase $this->assertArrayNotHasKey('disabled', $application->all()); } + public function testFindAlternativesDoesNotLoadSameNamespaceCommandsOnExactMatch() + { + $application = new Application(); + $application->setAutoExit(false); + + $loaded = []; + + $application->setCommandLoader(new FactoryCommandLoader([ + 'foo:bar' => function () use (&$loaded) { + $loaded['foo:bar'] = true; + + return (new Command('foo:bar'))->setCode(function () {}); + }, + 'foo' => function () use (&$loaded) { + $loaded['foo'] = true; + + return (new Command('foo'))->setCode(function () {}); + }, + ])); + + $application->run(new ArrayInput(['command' => 'foo']), new NullOutput()); + + $this->assertSame(['foo' => true], $loaded); + } + protected function getDispatcher($skipCommand = false) { $dispatcher = new EventDispatcher(); From 1c8fbe1cf9d5898094c3f88e582b37d6d4eaede4 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Thu, 13 Feb 2020 15:46:26 +0100 Subject: [PATCH 2/8] fix links to releases page (formerly known as "roadmap") --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .../Resources/views/Collector/config.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 57c1517854..859515b3ca 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,7 +11,7 @@ Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. -Additionally (see https://symfony.com/roadmap): +Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained branch where they apply diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 94912c5a71..58ec64d07e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -202,7 +202,7 @@ {{ collector.symfonyeom }} {{ collector.symfonyeol }} - View roadmap + View roadmap From 9b382590ee719a3aeaad11a91a1ff666c0da1a3a Mon Sep 17 00:00:00 2001 From: Adam Prickett Date: Tue, 11 Feb 2020 14:40:40 +0000 Subject: [PATCH 3/8] [Console] Handle zero row count in appendRow() for Table --- .../Component/Console/Helper/Table.php | 4 ++- .../Console/Tests/Helper/TableTest.php | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 24613bb994..e4a7423a18 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -601,7 +601,9 @@ class Table ++$numberOfRows; // Add row for header separator } - ++$numberOfRows; // Add row for footer separator + if (\count($this->rows) > 0) { + ++$numberOfRows; // Add row for footer separator + } return $numberOfRows; } diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 124309dd5b..c4acc3fbff 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -951,6 +951,38 @@ TABLE; $table->appendRow(['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25']); } + public function testSectionOutputHandlesZeroRowsAfterRender() + { + $sections = []; + $stream = $this->getOutputStream(true); + $output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter()); + $output->writeln('My Table'); + $table = new Table($output); + $table + ->setHeaders(['ISBN', 'Title', 'Author', 'Price']) + ->setRows([]); + + $table->render(); + + $table->appendRow(['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25']); + + $expected = + <<assertEquals($expected, $this->getOutputContent($output)); + } + public function testIsNotDefinedStyleException() { $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); From 5825e3c58c1b047606ea4c8526b7d93ded2f9a4e Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Thu, 13 Feb 2020 16:21:59 +0100 Subject: [PATCH 4/8] fix anchor --- .../Resources/views/Collector/config.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 58ec64d07e..b9d130b13e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -202,7 +202,7 @@ From 67ef532f8cfbc2678fd7ea862e80d95725935897 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 13 Feb 2020 19:40:02 +0100 Subject: [PATCH 5/8] [ErrorHandler] silence warning when zend.assertions=-1 --- src/Symfony/Component/ErrorHandler/Debug.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/ErrorHandler/Debug.php b/src/Symfony/Component/ErrorHandler/Debug.php index a3c0511d22..9cc8ec17a8 100644 --- a/src/Symfony/Component/ErrorHandler/Debug.php +++ b/src/Symfony/Component/ErrorHandler/Debug.php @@ -29,7 +29,7 @@ class Debug ini_set('display_errors', 1); } - ini_set('zend.assertions', 1); + @ini_set('zend.assertions', 1); ini_set('assert.active', 1); ini_set('assert.warning', 0); ini_set('assert.exception', 1); From 06f5a1113d3188e2abc43021ada4eb7bd82376ef Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 13 Feb 2020 19:35:54 +0100 Subject: [PATCH 6/8] [HttpFoundation] fix not sending Content-Type header for 204 responses --- src/Symfony/Component/HttpFoundation/Response.php | 4 +++- .../Component/HttpFoundation/Tests/ResponseTest.php | 12 ++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 05f740b6ad..b267cd8ceb 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -267,10 +267,12 @@ class Response $this->setContent(null); $headers->remove('Content-Type'); $headers->remove('Content-Length'); + // prevent PHP from sending the Content-Type header based on default_mimetype + ini_set('default_mimetype', ''); } else { // Content-type based on the Request if (!$headers->has('Content-Type')) { - $format = $request->getPreferredFormat(); + $format = $request->getPreferredFormat(null); if (null !== $format && $mimeType = $request->getMimeType($format)) { $headers->set('Content-Type', $mimeType); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index a2a5574f28..d5da59ad7e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -461,18 +461,10 @@ class ResponseTest extends ResponseTestCase public function testDefaultContentType() { - $headerMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->setMethods(['set'])->getMock(); - $headerMock->expects($this->at(0)) - ->method('set') - ->with('Content-Type', 'text/html'); - $headerMock->expects($this->at(1)) - ->method('set') - ->with('Content-Type', 'text/html; charset=UTF-8'); - $response = new Response('foo'); - $response->headers = $headerMock; - $response->prepare(new Request()); + + $this->assertSame('text/html; charset=UTF-8', $response->headers->get('Content-Type')); } public function testContentTypeCharset() From e1713862997b29dd91f7203da0db6d4ef38355d6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 14 Feb 2020 07:56:04 +0100 Subject: [PATCH 7/8] sync validator translation files with master --- .../Validator/Resources/translations/validators.de.xlf | 4 ++++ .../Validator/Resources/translations/validators.en.xlf | 4 ++++ .../Validator/Resources/translations/validators.fr.xlf | 4 ++++ .../Validator/Resources/translations/validators.ru.xlf | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf index 8ee3120482..0702e8dfcd 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf @@ -366,6 +366,10 @@ This value should be between {{ min }} and {{ max }}. Dieser Wert sollte zwischen {{ min }} und {{ max }} sein. + + This value is not a valid hostname. + Dieser Wert ist kein gültiger Hostname. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf index 100d552076..635e6736f6 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf @@ -366,6 +366,10 @@ This value should be between {{ min }} and {{ max }}. This value should be between {{ min }} and {{ max }}. + + This value is not a valid hostname. + This value is not a valid hostname. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf index dc7e73e3c7..4a7ab3538c 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf @@ -366,6 +366,10 @@ This value should be between {{ min }} and {{ max }}. Cette valeur doit être comprise entre {{ min }} et {{ max }}. + + This value is not a valid hostname. + Cette valeur n'est pas un nom d'hôte valide. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf index 361be20f79..80911a9902 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf @@ -366,6 +366,10 @@ This value should be between {{ min }} and {{ max }}. Значение должно быть между {{ min }} и {{ max }}. + + This value is not a valid hostname. + Значение не является корректным именем хоста. + From 9e431038b204c6ebe53b2d628c0df52df086bd4a Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Wed, 12 Feb 2020 22:21:47 +0100 Subject: [PATCH 8/8] fix unix root dir issue --- src/Symfony/Component/Finder/Finder.php | 4 ++++ .../Finder/Iterator/RecursiveDirectoryIterator.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index d2ea17d87a..33a76cc976 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -744,6 +744,10 @@ class Finder implements \IteratorAggregate, \Countable */ private function normalizeDir($dir) { + if ('/' === $dir) { + return $dir; + } + $dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR); if (preg_match('#^(ssh2\.)?s?ftp://#', $dir)) { diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index ab48a2b8a1..63764d407d 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -74,7 +74,11 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator } $subPathname .= $this->getFilename(); - return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname); + if ('/' !== $basePath = $this->rootPath) { + $basePath .= $this->directorySeparator; + } + + return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname); } /**
{{ collector.symfonyeom }} {{ collector.symfonyeol }} - View roadmap + View roadmap