From ab6abd5293aa292b6d14c56142acc4674b60f658 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Nov 2017 06:48:33 -0800 Subject: [PATCH 01/12] updated CHANGELOG for 3.4.0-RC2 --- CHANGELOG-3.4.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index ff448f9565..2e91b3fd9d 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -7,6 +7,22 @@ in 3.4 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.4.0...v3.4.1 +* 3.4.0-RC2 (2017-11-24) + + * bug #25146 [DI] Dont resolve envs in service ids (nicolas-grekas) + * bug #25113 [Routing] Fix "config-file-relative" annotation loader resources (nicolas-grekas, sroze) + * bug #25065 [FrameworkBundle] Update translation commands to work with default paths (yceruto) + * bug #25109 Make debug:container search command case-insensitive (jzawadzki) + * bug #25121 [FrameworkBundle] Fix AssetsInstallCommand (nicolas-grekas) + * bug #25102 [Form] Fixed ContextErrorException in FileType (chihiro-adachi) + * bug #25130 [DI] Fix handling of inlined definitions by ContainerBuilder (nicolas-grekas) + * bug #25119 [DI] Fix infinite loop when analyzing references (nicolas-grekas) + * bug #25094 [FrameworkBundle][DX] Display a nice error message if an enabled component is missing (derrabus) + * bug #25100 [SecurityBundle] providerIds is undefined error when firewall provider is not specified (karser) + * bug #25100 [SecurityBundle] providerIds is undefined error when firewall provider is not specified (karser) + * bug #25100 [SecurityBundle] providerIds is undefined error when firewall provider is not specified (karser) + * bug #25097 [Bridge\PhpUnit] Turn "preserveGlobalState" to false by default, revert "Blacklist" removal (nicolas-grekas) + * 3.4.0-RC1 (2017-11-21) * bug #25077 [Bridge/Twig] Let getFlashes starts the session (MatTheCat) From 75761741158669e4aa386f516cf53ed66b502dad Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Nov 2017 06:48:42 -0800 Subject: [PATCH 02/12] updated VERSION for 3.4.0-RC2 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index a30d5916f9..f714859845 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.0-DEV'; + const VERSION = '3.4.0-RC2'; const VERSION_ID = 30400; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = 'RC2'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 3502020834a401416c2c5d35e6ac6026d39fae72 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 23 Nov 2017 14:17:09 -0500 Subject: [PATCH 03/12] adding checks for the expression language --- .../Component/DependencyInjection/Loader/XmlFileLoader.php | 4 ++++ .../Component/DependencyInjection/Loader/YamlFileLoader.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index d839ab267d..598cf36f85 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -506,6 +506,10 @@ class XmlFileLoader extends FileLoader $arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior); break; case 'expression': + if (!class_exists(Expression::class)) { + throw new \LogicException(sprintf('The type="expression" attribute cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".')); + } + $arguments[$key] = new Expression($arg->nodeValue); break; case 'collection': diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 3af504d9e7..81d3ccb881 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -775,6 +775,10 @@ class YamlFileLoader extends FileLoader $value[$k] = $this->resolveServices($v, $file, $isParameter); } } elseif (is_string($value) && 0 === strpos($value, '@=')) { + if (!class_exists(Expression::class)) { + throw new \LogicException(sprintf('The "@=" expression syntax cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".')); + } + return new Expression(substr($value, 2)); } elseif (is_string($value) && 0 === strpos($value, '@')) { if (0 === strpos($value, '@@')) { From e52825e2533af77361ed7a424fb0952e9161ff2d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Nov 2017 07:20:16 -0800 Subject: [PATCH 04/12] bumped Symfony version to 3.4.0 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index f714859845..a30d5916f9 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.0-RC2'; + const VERSION = '3.4.0-DEV'; const VERSION_ID = 30400; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'RC2'; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From fd4340693c86317ba0e301f72c0e76fd8859fe24 Mon Sep 17 00:00:00 2001 From: Samuel ROZE Date: Fri, 24 Nov 2017 15:22:02 +0000 Subject: [PATCH 05/12] Automatically enable the CSRF protection if CSRF manager exists --- .../FrameworkBundle/DependencyInjection/Configuration.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index d5030fc9fe..c9dbd6af77 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -21,6 +21,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Form\Form; use Symfony\Component\Lock\Lock; use Symfony\Component\Lock\Store\SemaphoreStore; +use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Serializer\Serializer; use Symfony\Component\Translation\Translator; use Symfony\Component\Validator\Validation; @@ -142,7 +143,7 @@ class Configuration implements ConfigurationInterface $rootNode ->children() ->arrayNode('csrf_protection') - ->canBeEnabled() + ->{!class_exists(FullStack::class) && class_exists(CsrfTokenManagerInterface::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->end() ->end() ; From ced0857560bc8314a13055d03f368c630d61c6ac Mon Sep 17 00:00:00 2001 From: Gawain Lynch Date: Sun, 26 Nov 2017 11:31:13 +0100 Subject: [PATCH 06/12] Remove unreachable code --- .../Compiler/RegisterServiceSubscribersPass.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php index 8c81452b31..f8dba86a0b 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php @@ -74,9 +74,6 @@ class RegisterServiceSubscribersPass extends AbstractRecursivePass if ($optionalBehavior = '?' === $type[0]) { $type = substr($type, 1); $optionalBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; - } elseif ($optionalBehavior = '!' === $type[0]) { - $type = substr($type, 1); - $optionalBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; } if (is_int($key)) { $key = $type; From 7de1af4d53e974a1c728c3ba3c61082907e59b2e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 26 Nov 2017 18:11:23 +0100 Subject: [PATCH 07/12] [HttpKernel] Read $_ENV when checking SHELL_VERBOSITY --- src/Symfony/Component/HttpKernel/Log/Logger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Log/Logger.php b/src/Symfony/Component/HttpKernel/Log/Logger.php index 8facb03c5a..617efcf13e 100644 --- a/src/Symfony/Component/HttpKernel/Log/Logger.php +++ b/src/Symfony/Component/HttpKernel/Log/Logger.php @@ -42,8 +42,8 @@ class Logger extends AbstractLogger if (null === $minLevel) { $minLevel = LogLevel::WARNING; - if (isset($_SERVER['SHELL_VERBOSITY'])) { - switch ((int) $_SERVER['SHELL_VERBOSITY']) { + if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { + switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) { case -1: $minLevel = LogLevel::ERROR; break; case 1: $minLevel = LogLevel::NOTICE; break; case 2: $minLevel = LogLevel::INFO; break; From df4d6d6e16031501e896d1b1074e9ddd8330576e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 26 Nov 2017 21:27:09 +0100 Subject: [PATCH 08/12] don't override existing verbosity env var --- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index a30d5916f9..2f0453031f 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -120,7 +120,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl return; } - if ($this->debug && !isset($_SERVER['SHELL_VERBOSITY'])) { + if ($this->debug && !isset($_ENV['SHELL_VERBOSITY']) && !isset($_SERVER['SHELL_VERBOSITY'])) { putenv('SHELL_VERBOSITY=3'); $_ENV['SHELL_VERBOSITY'] = 3; $_SERVER['SHELL_VERBOSITY'] = 3; From 01edbf78023894c65128019ec62a24785bcdaed4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 27 Nov 2017 10:12:25 +0100 Subject: [PATCH 09/12] [FrameworkBundle] Make MicroKernelTraitTest green --- .../FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php index 2cb1ba8f7d..539306fcea 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php @@ -18,7 +18,7 @@ class MicroKernelTraitTest extends TestCase { public function test() { - $kernel = new ConcreteMicroKernel('test', true); + $kernel = new ConcreteMicroKernel('test', false); $kernel->boot(); $request = Request::create('/'); @@ -31,7 +31,7 @@ class MicroKernelTraitTest extends TestCase public function testAsEventSubscriber() { - $kernel = new ConcreteMicroKernel('test', true); + $kernel = new ConcreteMicroKernel('test', false); $kernel->boot(); $request = Request::create('/danger'); From 6e622c668b40366ed35be456c7e7c5476b1ca3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 26 Nov 2017 15:56:42 +0100 Subject: [PATCH 10/12] [DI] Prevent a ReflectionException during cache:clear when the parent class doesn't exist --- .../DependencyInjection/Dumper/PhpDumper.php | 2 +- .../Tests/Fixtures/ParentNotExists.php | 7 +++++++ .../containers/container_inline_requires.php | 2 ++ .../Tests/Fixtures/php/container_inline_requires.php | 12 ++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 0a33fb3083..ca9f263094 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -378,7 +378,7 @@ EOTXT; if (isset($lineage[$class])) { return; } - if (!$r = $this->container->getReflectionClass($class)) { + if (!$r = $this->container->getReflectionClass($class, false)) { return; } if ($this->container instanceof $class) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php new file mode 100644 index 0000000000..ae637f917f --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php @@ -0,0 +1,7 @@ +register(HotPath\C1::class)->addTag('container.hot_path')->setPublic(true); $container->register(HotPath\C2::class)->addArgument(new Reference(HotPath\C3::class))->setPublic(true); $container->register(HotPath\C3::class); +$container->register(ParentNotExists::class)->setPublic(true); return $container; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_inline_requires.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_inline_requires.php index d3d94290fd..c888dc997d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_inline_requires.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_inline_requires.php @@ -32,8 +32,10 @@ class ProjectServiceContainer extends Container 'symfony\\component\\dependencyinjection\\tests\\fixtures\\includes\\hotpath\\c1' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C1', 'symfony\\component\\dependencyinjection\\tests\\fixtures\\includes\\hotpath\\c2' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2', 'symfony\\component\\dependencyinjection\\tests\\fixtures\\includes\\hotpath\\c3' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C3', + 'symfony\\component\\dependencyinjection\\tests\\fixtures\\parentnotexists' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\ParentNotExists', ); $this->methodMap = array( + 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\ParentNotExists' => 'getParentNotExistsService', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C1' => 'getC1Service', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2' => 'getC2Service', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C3' => 'getC3Service', @@ -75,6 +77,16 @@ class ProjectServiceContainer extends Container return true; } + /** + * Gets the public 'Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists' shared service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists + */ + protected function getParentNotExistsService() + { + return $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists(); + } + /** * Gets the public 'Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C1' shared service. * From eab90ef1cf61b8921a50d1c0da99c9e6900ffb20 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 27 Nov 2017 15:08:03 +0100 Subject: [PATCH 11/12] modify definitions only if the do exist If the `TranslatorPass` is used an application without the Console component, the commands will not be registered. Thus, their service definitions must not be modified. --- .../Translation/DependencyInjection/TranslatorPass.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php index a5e4097843..db2a2a1ecc 100644 --- a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php +++ b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php @@ -80,8 +80,15 @@ class TranslatorPass implements CompilerPassInterface ->replaceArgument(3, $loaders) ; - if ($container->hasParameter('twig.default_path')) { + if (!$container->hasParameter('twig.default_path')) { + return; + } + + if ($container->hasDefinition($this->debugCommandServiceId)) { $container->getDefinition($this->debugCommandServiceId)->replaceArgument(4, $container->getParameter('twig.default_path')); + } + + if ($container->hasDefinition($this->updateCommandServiceId)) { $container->getDefinition($this->updateCommandServiceId)->replaceArgument(5, $container->getParameter('twig.default_path')); } } From 3a873f887762d1ca7df8693276c2b7ebe583dff3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 27 Nov 2017 16:08:42 +0100 Subject: [PATCH 12/12] [HttpKernel] Better handling of legacy cache --- src/Symfony/Component/HttpKernel/Kernel.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 2f0453031f..97d23b2096 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -581,8 +581,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl $class = $this->getContainerClass(); $cacheDir = $this->warmupDir ?: $this->getCacheDir(); $cache = new ConfigCache($cacheDir.'/'.$class.'.php', $this->debug); - $fresh = true; - if (!$cache->isFresh()) { + if ($fresh = $cache->isFresh()) { + $this->container = require $cache->getPath(); + $fresh = \is_object($this->container); + } + if (!$fresh) { if ($this->debug) { $collectedLogs = array(); $previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) { @@ -632,11 +635,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl $oldContainer = file_exists($cache->getPath()) && is_object($oldContainer = @include $cache->getPath()) ? new \ReflectionClass($oldContainer) : false; $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); - - $fresh = false; + $this->container = require $cache->getPath(); } - $this->container = require $cache->getPath(); $this->container->set('kernel', $this); if ($fresh) {