diff --git a/UPGRADE-4.1.md b/UPGRADE-4.1.md index 8155492899..f482308f72 100644 --- a/UPGRADE-4.1.md +++ b/UPGRADE-4.1.md @@ -47,6 +47,11 @@ Translation * The `FileDumper::setBackup()` method is deprecated and will be removed in 5.0. * The `TranslationWriter::disableBackup()` method is deprecated and will be removed in 5.0. +TwigBundle +---------- + + * Deprecated relying on the default value (`false`) of the `twig.strict_variables` configuration option. You should use `%kernel.debug%` explicitly instead, which will be the new default in 5.0. + Validator -------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 7356161a89..c09d25b4ad 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -40,6 +40,11 @@ Translation * The `FileDumper::setBackup()` method has been removed. * The `TranslationWriter::disableBackup()` method has been removed. +TwigBundle +---------- + + * The default value (`false`) of the `twig.strict_variables` configuration option has been changed to `%kernel.debug%`. + Validator -------- diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml index d6ed10e896..cf92920f4b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml @@ -1,5 +1,5 @@ imports: - - { resource: ./../config/framework.yml } + - { resource: ./../config/default.yml } security: encoders: diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/custom_handlers.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/custom_handlers.yml index e15e203c62..dff93273e8 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/custom_handlers.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/custom_handlers.yml @@ -1,5 +1,5 @@ imports: - - { resource: ./../config/framework.yml } + - { resource: ./../config/default.yml } security: encoders: diff --git a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md index 040ee68a4a..78b289092e 100644 --- a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * added priority to Twig extensions + * deprecated relying on the default value (`false`) of the `twig.strict_variables` configuration option. The `%kernel.debug%` parameter will be the new default in 5.0 4.0.0 ----- diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index f4488c0d5c..e2e4c56579 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -127,7 +127,13 @@ class Configuration implements ConfigurationInterface ->scalarNode('cache')->defaultValue('%kernel.cache_dir%/twig')->end() ->scalarNode('charset')->defaultValue('%kernel.charset%')->end() ->booleanNode('debug')->defaultValue('%kernel.debug%')->end() - ->booleanNode('strict_variables')->end() + ->booleanNode('strict_variables') + ->defaultValue(function () { + @trigger_error('Relying on the default value ("false") of the "twig.strict_variables" configuration option is deprecated since Symfony 4.1. You should use "%kernel.debug%" explicitly instead, which will be the new default in 5.0.', E_USER_DEPRECATED); + + return false; + }) + ->end() ->scalarNode('auto_reload')->end() ->integerNode('optimizations')->min(-1)->end() ->scalarNode('default_path') diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php index d3f8652c4b..bd8482cd9e 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -20,6 +20,7 @@ class ConfigurationTest extends TestCase public function testDoNoDuplicateDefaultFormResources() { $input = array( + 'strict_variables' => false, // to be removed in 5.0 relying on default 'form_themes' => array('form_div_layout.html.twig'), ); @@ -28,4 +29,16 @@ class ConfigurationTest extends TestCase $this->assertEquals(array('form_div_layout.html.twig'), $config['form_themes']); } + + /** + * @group legacy + * @expectedDeprecation Relying on the default value ("false") of the "twig.strict_variables" configuration option is deprecated since Symfony 4.1. You should use "%kernel.debug%" explicitly instead, which will be the new default in 5.0. + */ + public function testGetStrictVariablesDefaultFalse() + { + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(), array(array())); + + $this->assertFalse($config['strict_variables']); + } } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php index ab429237bb..5ef1256663 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php @@ -3,4 +3,5 @@ $container->loadFromExtension('twig', array( 'autoescape_service' => 'my_project.some_bundle.template_escaping_guesser', 'autoescape_service_method' => 'guess', + 'strict_variables' => false, // to be removed in 5.0 relying on default )); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php index efd2df5f47..674c5d474c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php @@ -1,3 +1,5 @@ loadFromExtension('twig', array()); +$container->loadFromExtension('twig', array( + 'strict_variables' => false, // to be removed in 5.0 relying on default +)); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php index 28b8281a99..da234511b1 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php @@ -1,7 +1,8 @@ loadFromExtension('twig', array( - 'paths' => array( - 'namespaced_path3' => 'namespace3', - ), + 'paths' => array( + 'namespaced_path3' => 'namespace3', + ), + 'strict_variables' => false, // to be removed in 5.0 relying on default )); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php index 630a9a9edc..fe4f7c19c1 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php @@ -11,4 +11,5 @@ $container->loadFromExtension('twig', array( 'decimal_point' => ',', 'thousands_separator' => '.', ), + 'strict_variables' => false, // to be removed in 5.0 relying on default )); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml index fa28361cc8..39ab94953e 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml @@ -6,5 +6,5 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml index 771e382e47..30a7229aee 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml @@ -6,5 +6,5 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml index 1ab39e4922..ea642a8b8c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml index eb26e7165b..34e301c095 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml @@ -1,3 +1,4 @@ twig: autoescape_service: my_project.some_bundle.template_escaping_guesser autoescape_service_method: guess + strict_variables: false # to be removed in 5.0 relying on default diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml index a472b2698e..9b5dbcf35b 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml @@ -1 +1,2 @@ twig: + strict_variables: false # to be removed in 5.0 relying on default diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml index 3c5e6a3b59..41a281cc81 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml @@ -1,3 +1,4 @@ twig: + strict_variables: false # to be removed in 5.0 relying on default paths: namespaced_path3: namespace3 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml index 290921630f..a5c57f383e 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml @@ -1,4 +1,5 @@ twig: + strict_variables: false # to be removed in 5.0 relying on default date: format: Y-m-d interval_format: '%d' diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index fa4264f2e2..ca0e2387fd 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -29,7 +29,9 @@ class TwigExtensionTest extends TestCase { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', array()); + $container->loadFromExtension('twig', array( + 'strict_variables' => false, // to be removed in 5.0 relying on default + )); $this->compileContainer($container); $this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); @@ -151,7 +153,10 @@ class TwigExtensionTest extends TestCase $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', array('globals' => $globals)); + $container->loadFromExtension('twig', array( + 'globals' => $globals, + 'strict_variables' => false, // // to be removed in 5.0 relying on default + )); $this->compileContainer($container); $calls = $container->getDefinition('twig')->getMethodCalls(); @@ -217,7 +222,9 @@ class TwigExtensionTest extends TestCase $container->register('debug.stopwatch', 'Symfony\Component\Stopwatch\Stopwatch'); } $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', array()); + $container->loadFromExtension('twig', array( + 'strict_variables' => false, // to be removed in 5.0 relying on default + )); $container->setAlias('test.twig.extension.debug.stopwatch', 'twig.extension.debug.stopwatch')->setPublic(true); $this->compileContainer($container); @@ -242,7 +249,9 @@ class TwigExtensionTest extends TestCase { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', array()); + $container->loadFromExtension('twig', array( + 'strict_variables' => false, // to be removed in 5.0 relying on default + )); $container->setParameter('kernel.environment', 'test'); $container->setParameter('debug.file_link_format', 'test'); $container->setParameter('foo', 'FooClass'); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php index a21c11adca..ce53eb9e96 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php @@ -89,10 +89,15 @@ class CacheWarmingKernel extends Kernel public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(function ($container) { - $container->loadFromExtension('framework', array( - 'secret' => '$ecret', - 'form' => array('enabled' => false), - )); + $container + ->loadFromExtension('framework', array( + 'secret' => '$ecret', + 'form' => array('enabled' => false), + )) + ->loadFromExtension('twig', array( // to be removed in 5.0 relying on default + 'strict_variables' => false, + )) + ; }); if ($this->withTemplating) { diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php index 952b5e6ae1..f3d636c177 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php @@ -61,10 +61,15 @@ class NoTemplatingEntryKernel extends Kernel public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(function ($container) { - $container->loadFromExtension('framework', array( - 'secret' => '$ecret', - 'form' => array('enabled' => false), - )); + $container + ->loadFromExtension('framework', array( + 'secret' => '$ecret', + 'form' => array('enabled' => false), + )) + ->loadFromExtension('twig', array( // to be removed in 5.0 relying on default + 'strict_variables' => false, + )) + ; }); }