From 534d9fc560a1d25b30148debae80a752cae4bc55 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 22 Jul 2015 09:03:09 +0100 Subject: [PATCH 1/9] [Console] Fix console output with closed stdout --- .../Console/Output/ConsoleOutput.php | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Output/ConsoleOutput.php b/src/Symfony/Component/Console/Output/ConsoleOutput.php index 708d171445..50ef4df900 100644 --- a/src/Symfony/Component/Console/Output/ConsoleOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleOutput.php @@ -46,12 +46,9 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface */ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) { - $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output'; - $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output'; + parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); - parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter); - - $this->stderr = new StreamOutput(fopen($errorStream, 'w'), $verbosity, $decorated, $this->getFormatter()); + $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter()); } /** @@ -129,4 +126,24 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface { return 'OS400' === php_uname('s'); } + + /** + * @return resource + */ + private function openOutputStream() + { + $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output'; + + return @fopen($outputStream, 'w') ?: fopen('php://output', 'w'); + } + + /** + * @return resource + */ + private function openErrorStream() + { + $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output'; + + return fopen($errorStream, 'w'); + } } From d3874eca2cdbd1d3e915e1666c6f4aff9f93390e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 22 Jul 2015 13:57:38 +0200 Subject: [PATCH 2/9] [travis] Tests deps=low with PHP 5.6 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a780aa1d61..b27111e496 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ matrix: - php: 5.4 - php: 5.5 - php: 5.6 - - php: 5.3 env: deps=low - php: 5.6 env: deps=high From 1fc03155d4fd869ac629e91c49862122c7a1e389 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Wed, 22 Jul 2015 15:05:05 +0200 Subject: [PATCH 3/9] [Security] removed useless else condition in SwitchUserListener class. --- .../Component/Security/Http/Firewall/SwitchUserListener.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php index c5ecf780f5..79b715aa3c 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php @@ -116,9 +116,9 @@ class SwitchUserListener implements ListenerInterface if (false !== $originalToken) { if ($token->getUsername() === $request->get($this->usernameParameter)) { return $token; - } else { - throw new \LogicException(sprintf('You are already switched to "%s" user.', $token->getUsername())); } + + throw new \LogicException(sprintf('You are already switched to "%s" user.', $token->getUsername())); } if (false === $this->accessDecisionManager->decide($token, array($this->role))) { From a1772b6a23e847d60bdd54db66cb7539a9260db8 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Sat, 25 Jul 2015 14:51:32 +0300 Subject: [PATCH 4/9] [Asset] removed unused private property. --- src/Symfony/Component/Asset/UrlPackage.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/Asset/UrlPackage.php b/src/Symfony/Component/Asset/UrlPackage.php index 0e9f82d0fa..6381a9c1cd 100644 --- a/src/Symfony/Component/Asset/UrlPackage.php +++ b/src/Symfony/Component/Asset/UrlPackage.php @@ -36,7 +36,6 @@ use Symfony\Component\Asset\Exception\LogicException; class UrlPackage extends Package { private $baseUrls = array(); - private $sslUrls; private $sslPackage; /** @@ -62,7 +61,7 @@ class UrlPackage extends Package $sslUrls = $this->getSslUrls($baseUrls); if ($sslUrls && $baseUrls !== $sslUrls) { - $this->sslPackage = new UrlPackage($sslUrls, $versionStrategy); + $this->sslPackage = new self($sslUrls, $versionStrategy); } } From e3914460f377b0e5f94a5d3028c5914139c5210b Mon Sep 17 00:00:00 2001 From: Vincent AUBERT Date: Fri, 24 Jul 2015 21:28:02 +0200 Subject: [PATCH 5/9] #15331 add infos about deprecated classes to UPGRADE-3.0 --- UPGRADE-3.0.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index f8dcd0b5e4..c819bc8987 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -272,6 +272,17 @@ UPGRADE FROM 2.x to 3.0 ```php echo $form->getErrors(true, false); ``` + * The `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList` class has been removed in + favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. + + * The `Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList` class has been removed in + favor of `Symfony\Component\Form\ChoiceList\LazyChoiceList`. + + * The `Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList` class has been removed in + favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. + + * The `Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList` class has been removed in + favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. ### FrameworkBundle From aa7cbbd2053f56564450313d5d2e763df17a2a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20S=C3=A1nchez?= Date: Wed, 22 Jul 2015 16:34:23 -0300 Subject: [PATCH 6/9] Introduce failing test case when a SplFileInfo object is passed to the extract() method in the TwigExtractor. The problem is that when there's a twig error, symfony expects the `getRelativePath` method that the native object doesn't have. --- .../Twig/Tests/Translation/TwigExtractorTest.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 94ac80d884..f2b15fc5da 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -74,14 +74,26 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Twig_Error * @expectedExceptionMessageRegExp /Unclosed "block" in "extractor(\/|\\)syntax_error\.twig" at line 1/ + * @dataProvider resourcesWithSyntaxErrorsProvider */ - public function testExtractSyntaxError() + public function testExtractSyntaxError($resources) { $twig = new \Twig_Environment(new \Twig_Loader_Array(array())); $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface'))); $extractor = new TwigExtractor($twig); - $extractor->extract(__DIR__.'/../Fixtures', new MessageCatalogue('en')); + $extractor->extract($resources, new MessageCatalogue('en')); + } + + /** + * @return array + */ + public function resourcesWithSyntaxErrorsProvider() + { + return array( + array(__DIR__.'/../Fixtures'), + array(new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')), + ); } /** From 2bf78e5f20d0d6ce60e052c9dcb0ae31da604305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20S=C3=A1nchez?= Date: Thu, 23 Jul 2015 09:53:04 -0300 Subject: [PATCH 7/9] Resources as string have the same problem --- src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index f2b15fc5da..fb860ec2ad 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -92,6 +92,7 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase { return array( array(__DIR__.'/../Fixtures'), + array(__DIR__.'/../Fixtures/extractor/syntax_error.twig'), array(new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')), ); } From 1e15761ac722e2459ebc775025e33f22cc996cc1 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 26 Jul 2015 08:27:26 +0200 Subject: [PATCH 8/9] [TwigBridge] type-dependent path discovery With the introduction of the `AbstractFileExtractor` in Symfony 2.7, the `extract()` method in the `TwigExtractor` class does not necessarily deal with `SplFileInfo` instances from the Finder component, but also receives `\SplFileInfo` objects initialized by the base extractor class. --- .../Bridge/Twig/Tests/Translation/TwigExtractorTest.php | 2 +- src/Symfony/Bridge/Twig/Translation/TwigExtractor.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index fb860ec2ad..610d5a6068 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -73,7 +73,7 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Twig_Error - * @expectedExceptionMessageRegExp /Unclosed "block" in "extractor(\/|\\)syntax_error\.twig" at line 1/ + * @expectedExceptionMessageRegExp /Unclosed "block" in ".*extractor(\/|\\)syntax_error\.twig" at line 1/ * @dataProvider resourcesWithSyntaxErrorsProvider */ public function testExtractSyntaxError($resources) diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php index ad3fd9fe33..d892fe7303 100644 --- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php +++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Twig\Translation; use Symfony\Component\Finder\Finder; +use Symfony\Component\Finder\SplFileInfo; use Symfony\Component\Translation\Extractor\AbstractFileExtractor; use Symfony\Component\Translation\Extractor\ExtractorInterface; use Symfony\Component\Translation\MessageCatalogue; @@ -60,7 +61,11 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface try { $this->extractTemplate(file_get_contents($file->getPathname()), $catalogue); } catch (\Twig_Error $e) { - $e->setTemplateFile($file->getRelativePathname()); + if ($file instanceof SplFileInfo) { + $e->setTemplateFile($file->getRelativePathname()); + } elseif ($file instanceof \SplFileInfo) { + $e->setTemplateFile($file->getRealPath()); + } throw $e; } From adc6b3067da4a677204833a17894d108018ca6bc Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 22 Jul 2015 08:30:32 +0200 Subject: [PATCH 9/9] [Yaml] throw a ParseException on invalid data type Without this check, PHP would trigger a warning when an array was passed to `trim()`. The parser must throw a `ParseException` instance on a malformed YAML string instead. --- src/Symfony/Component/Yaml/Parser.php | 2 +- src/Symfony/Component/Yaml/Tests/ParserTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index cd5e1dc571..311ef18a37 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -234,7 +234,7 @@ class Parser } // 1-liner optionally followed by newline(s) - if ($this->lines[0] === trim($value)) { + if (is_string($value) && $this->lines[0] === trim($value)) { try { $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs); } catch (ParseException $e) { diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 6e39e7dc66..f434d5585d 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -551,6 +551,21 @@ EOF ); } + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage missing colon + */ + public function testScalarInSequence() + { + Yaml::parse(<< It is an error for two equal keys to appear in the same mapping node. * > In such a case the YAML processor may continue, ignoring the second