From 640b95a8f2ac3298d65b13d59f21c48bcbe30f43 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 4 Sep 2015 22:24:52 +0200 Subject: [PATCH] [FrameworkBundle] Removed deprecated code paths --- .../FrameworkBundle/Controller/Controller.php | 4 - .../Compiler/FragmentRendererPass.php | 49 -------- .../DependencyInjection/Configuration.php | 36 +----- .../FrameworkExtension.php | 16 +-- ...ContainerAwareHIncludeFragmentRenderer.php | 55 --------- .../Resources/config/schema/symfony-1.0.xsd | 6 - .../Templating/GlobalVariables.php | 17 --- .../Templating/Helper/RequestHelper.php | 30 +---- .../Templating/Helper/SessionHelper.php | 19 +-- .../LegacyFragmentRendererPassTest.php | 112 ------------------ .../DependencyInjection/ConfigurationTest.php | 8 +- .../DependencyInjection/Fixtures/php/csrf.php | 1 - .../Fixtures/php/csrf_disabled.php | 6 +- .../Fixtures/php/csrf_needs_session.php | 6 +- .../php/form_csrf_sets_field_name.php | 8 +- .../form_csrf_under_form_sets_field_name.php | 4 - .../DependencyInjection/Fixtures/php/full.php | 4 +- .../DependencyInjection/Fixtures/xml/csrf.xml | 2 - .../Fixtures/xml/csrf_disabled.xml | 4 +- .../Fixtures/xml/csrf_needs_session.xml | 4 +- .../xml/form_csrf_sets_field_name.xml | 5 +- .../form_csrf_under_form_sets_field_name.xml | 1 - .../DependencyInjection/Fixtures/xml/full.xml | 3 +- .../Fixtures/xml/legacy_templating_assets.xml | 23 ---- .../xml/legacy_templating_url_package.xml | 19 --- .../DependencyInjection/Fixtures/yml/csrf.yml | 3 - .../Fixtures/yml/csrf_disabled.yml | 3 +- .../Fixtures/yml/csrf_needs_session.yml | 3 +- .../yml/form_csrf_sets_field_name.yml | 5 - .../form_csrf_under_form_sets_field_name.yml | 2 - .../DependencyInjection/Fixtures/yml/full.yml | 2 - .../FrameworkExtensionTest.php | 36 ------ ...ainerAwareHIncludeFragmentRendererTest.php | 33 ------ .../Tests/Functional/app/config/framework.yml | 6 +- .../Tests/Templating/GlobalVariablesTest.php | 12 -- .../Resources/config/security.xml | 5 - .../SecurityDataCollectorTest.php | 18 --- .../app/FirewallEntryPoint/config.yml | 6 +- .../Tests/Functional/app/config/framework.yml | 6 +- 39 files changed, 49 insertions(+), 533 deletions(-) delete mode 100644 src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/FragmentRendererPass.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_url_package.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_sets_field_name.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index e67538642c..9f2eaec4dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -327,10 +327,6 @@ abstract class Controller extends ContainerAware */ protected function get($id) { - if ('request' === $id) { - @trigger_error('The "request" service is deprecated and will be removed in 3.0. Add a typehint for Symfony\\Component\\HttpFoundation\\Request to your controller parameters to retrieve the request instead.', E_USER_DEPRECATED); - } - return $this->container->get($id); } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/FragmentRendererPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/FragmentRendererPass.php deleted file mode 100644 index 5bcf932c21..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/FragmentRendererPass.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; - -@trigger_error('The '.__NAMESPACE__.'\FragmentRendererPass class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass instead.', E_USER_DEPRECATED); - -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; - -/** - * Adds services tagged kernel.fragment_renderer as HTTP content rendering strategies. - * - * @author Fabien Potencier - * - * @deprecated since version 2.7, to be removed in 3.0. Use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass instead. - */ -class FragmentRendererPass implements CompilerPassInterface -{ - public function process(ContainerBuilder $container) - { - if (false === $container->hasDefinition('fragment.handler')) { - return; - } - - $definition = $container->getDefinition('fragment.handler'); - foreach (array_keys($container->findTaggedServiceIds('kernel.fragment_renderer')) as $id) { - // We must assume that the class value has been correctly filled, even if the service is created by a factory - $class = $container->getDefinition($id)->getClass(); - - $refClass = new \ReflectionClass($class); - $interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface'; - if (!$refClass->implementsInterface($interface)) { - throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); - } - - $definition->addMethodCall('addRenderer', array(new Reference($id))); - } - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index db3378da6a..4c83c9f6dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -43,16 +43,6 @@ class Configuration implements ConfigurationInterface $rootNode = $treeBuilder->root('framework'); $rootNode - // Check deprecations before the config is processed to ensure - // the setting has been explicitly defined in a configuration file. - ->beforeNormalization() - ->ifTrue(function ($v) { return isset($v['csrf_protection']['field_name']); }) - ->then(function ($v) { - @trigger_error('The framework.csrf_protection.field_name configuration key is deprecated since version 2.4 and will be removed in 3.0. Use the framework.form.csrf_protection.field_name configuration key instead', E_USER_DEPRECATED); - - return $v; - }) - ->end() ->children() ->scalarNode('secret')->end() ->scalarNode('http_method_override') @@ -95,7 +85,6 @@ class Configuration implements ConfigurationInterface ->end() ; - $this->addCsrfSection($rootNode); $this->addFormSection($rootNode); $this->addEsiSection($rootNode); $this->addSsiSection($rootNode); @@ -115,23 +104,6 @@ class Configuration implements ConfigurationInterface return $treeBuilder; } - private function addCsrfSection(ArrayNodeDefinition $rootNode) - { - $rootNode - ->children() - ->arrayNode('csrf_protection') - ->canBeEnabled() - ->children() - ->scalarNode('field_name') - ->defaultValue('_token') - ->info('Deprecated since version 2.4, to be removed in 3.0. Use form.csrf_protection.field_name instead') - ->end() - ->end() - ->end() - ->end() - ; - } - private function addFormSection(ArrayNodeDefinition $rootNode) { $rootNode @@ -141,13 +113,9 @@ class Configuration implements ConfigurationInterface ->canBeEnabled() ->children() ->arrayNode('csrf_protection') - ->treatFalseLike(array('enabled' => false)) - ->treatTrueLike(array('enabled' => true)) - ->treatNullLike(array('enabled' => true)) - ->addDefaultsIfNotSet() + ->canBeEnabled() ->children() - ->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled - ->scalarNode('field_name')->defaultNull()->end() + ->scalarNode('field_name')->defaultValue('_token')->end() ->end() ->end() ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 6fa00bea6a..e7f8ea49c0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -97,13 +97,9 @@ class FrameworkExtension extends Extension if (!class_exists('Symfony\Component\Validator\Validation')) { throw new LogicException('The Validator component is required to use the Form component.'); } - - if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) { - $config['csrf_protection']['enabled'] = true; - } } - $this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader); + $this->registerSecurityCsrfConfiguration($config['form']['csrf_protection'], $container, $loader); if (isset($config['assets'])) { $this->registerAssetsConfiguration($config['assets'], $container, $loader); @@ -200,20 +196,12 @@ class FrameworkExtension extends Extension private function registerFormConfiguration($config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('form.xml'); - if (null === $config['form']['csrf_protection']['enabled']) { - $config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled']; - } if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) { $loader->load('form_csrf.xml'); $container->setParameter('form.type_extension.csrf.enabled', true); - - if (null !== $config['form']['csrf_protection']['field_name']) { - $container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']); - } else { - $container->setParameter('form.type_extension.csrf.field_name', $config['csrf_protection']['field_name']); - } + $container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']); } else { $container->setParameter('form.type_extension.csrf.enabled', false); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php b/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php deleted file mode 100644 index 919ec8af30..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Fragment; - -@trigger_error('The '.__NAMESPACE__.'\ContainerAwareHIncludeFragmentRenderer class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Bundle\FrameworkBundle\Fragment\HIncludeFragmentRenderer instead.', E_USER_DEPRECATED); - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\UriSigner; -use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; - -/** - * Implements the Hinclude rendering strategy. - * - * @author Fabien Potencier - * - * @deprecated since version 2.7, to be removed in 3.0. Use Symfony\Bundle\FrameworkBundle\Fragment\HIncludeFragmentRenderer instead. - */ -class ContainerAwareHIncludeFragmentRenderer extends HIncludeFragmentRenderer -{ - private $container; - - /** - * {@inheritdoc} - */ - public function __construct(ContainerInterface $container, UriSigner $signer = null, $globalDefaultTemplate = null) - { - $this->container = $container; - - parent::__construct(null, $signer, $globalDefaultTemplate, $container->getParameter('kernel.charset')); - } - - /** - * {@inheritdoc} - */ - public function render($uri, Request $request, array $options = array()) - { - // setting the templating cannot be done in the constructor - // as it would lead to an infinite recursion in the service container - if (!$this->hasTemplating()) { - $this->setTemplating($this->container->get('templating')); - } - - return parent::render($uri, $request, $options); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index eecbf1b653..9dd9802274 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -20,7 +20,6 @@ - @@ -55,11 +54,6 @@ - - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php b/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php index 687588b1b9..606e886415 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php @@ -14,7 +14,6 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\Security\Core\SecurityContext; /** * GlobalVariables is the entry point for Symfony global variables in PHP templates. @@ -33,22 +32,6 @@ class GlobalVariables $this->container = $container; } - /** - * Returns the security context service. - * - * @deprecated since version 2.6, to be removed in 3.0. - * - * @return SecurityContext|null The security context - */ - public function getSecurity() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED); - - if ($this->container->has('security.context')) { - return $this->container->get('security.context'); - } - } - /** * Returns the current user. * diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php index ec28f12ba6..694e375fb2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -22,26 +21,11 @@ use Symfony\Component\HttpFoundation\RequestStack; */ class RequestHelper extends Helper { - protected $request; protected $requestStack; - /** - * Constructor. - * - * @param Request|RequestStack $requestStack A RequestStack instance or a Request instance - * - * @deprecated since version 2.5, passing a Request instance is deprecated and support for it will be removed in 3.0. - */ - public function __construct($requestStack) + public function __construct(RequestStack $requestStack) { - if ($requestStack instanceof Request) { - @trigger_error('Since version 2.5, passing a Request instance into the '.__METHOD__.' is deprecated and support for it will be removed in 3.0. Inject a Symfony\Component\HttpFoundation\RequestStack instance instead.', E_USER_DEPRECATED); - $this->request = $requestStack; - } elseif ($requestStack instanceof RequestStack) { - $this->requestStack = $requestStack; - } else { - throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.'); - } + $this->requestStack = $requestStack; } /** @@ -71,15 +55,11 @@ class RequestHelper extends Helper private function getRequest() { - if ($this->requestStack) { - if (!$this->requestStack->getCurrentRequest()) { - throw new \LogicException('A Request must be available.'); - } - - return $this->requestStack->getCurrentRequest(); + if (!$this->requestStack->getCurrentRequest()) { + throw new \LogicException('A Request must be available.'); } - return $this->request; + return $this->requestStack->getCurrentRequest(); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php index 5d15fa3464..15ec1a9cd1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; use Symfony\Component\Templating\Helper\Helper; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -25,23 +24,9 @@ class SessionHelper extends Helper protected $session; protected $requestStack; - /** - * Constructor. - * - * @param Request|RequestStack $requestStack A RequestStack instance or a Request instance - * - * @deprecated since version 2.5, passing a Request instance is deprecated and support for it will be removed in 3.0. - */ - public function __construct($requestStack) + public function __construct(RequestStack $requestStack) { - if ($requestStack instanceof Request) { - @trigger_error('Since version 2.5, passing a Request instance into the '.__METHOD__.' is deprecated and support for it will be removed in 3.0. Inject a Symfony\Component\HttpFoundation\RequestStack instance instead.', E_USER_DEPRECATED); - $this->session = $requestStack->getSession(); - } elseif ($requestStack instanceof RequestStack) { - $this->requestStack = $requestStack; - } else { - throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.'); - } + $this->requestStack = $requestStack; } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php deleted file mode 100644 index 97c98d5d8f..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FragmentRendererPass; - -/** - * @group legacy - */ -class LegacyFragmentRendererPassTest extends \PHPUnit_Framework_TestCase -{ - /** - * Tests that content rendering not implementing FragmentRendererInterface - * trigger an exception. - * - * @expectedException \InvalidArgumentException - */ - public function testContentRendererWithoutInterface() - { - // one service, not implementing any interface - $services = array( - 'my_content_renderer' => array(), - ); - - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('stdClass')); - - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition') - ); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.fragment_renderer here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->returnValue($services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->returnValue($definition)); - - $pass = new FragmentRendererPass(); - $pass->process($builder); - } - - public function testValidContentRenderer() - { - $services = array( - 'my_content_renderer' => array(), - ); - - $renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $renderer - ->expects($this->once()) - ->method('addMethodCall') - ->with('addRenderer', array(new Reference('my_content_renderer'))) - ; - - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\RendererService')); - - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition') - ); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.fragment_renderer here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->returnValue($services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->onConsecutiveCalls($renderer, $definition)); - - $pass = new FragmentRendererPass(); - $pass->process($builder); - } -} - -class RendererService implements \Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface -{ - public function render($uri, Request $request = null, array $options = array()) - { - } - - public function getName() - { - return 'test'; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 6cebd50ae8..3a10c54b31 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -126,14 +126,10 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase 'form' => array( 'enabled' => false, 'csrf_protection' => array( - 'enabled' => null, // defaults to csrf_protection.enabled - 'field_name' => null, + 'enabled' => false, + 'field_name' => '_token', ), ), - 'csrf_protection' => array( - 'enabled' => false, - 'field_name' => '_token', - ), 'esi' => array('enabled' => false), 'ssi' => array('enabled' => false), 'fragments' => array( diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php index 0c34ad1089..3fe497dce8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php @@ -1,7 +1,6 @@ loadFromExtension('framework', array( - 'csrf_protection' => true, 'form' => array( 'enabled' => true, 'csrf_protection' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_disabled.php index b7bbd8bf3c..7360c49c72 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_disabled.php @@ -1,7 +1,9 @@ loadFromExtension('framework', array( - 'csrf_protection' => array( - 'enabled' => false, + 'form' => array( + 'csrf_protection' => array( + 'enabled' => false, + ), ), )); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php index d1df1c5962..4e0fce8a2d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php @@ -1,7 +1,9 @@ loadFromExtension('framework', array( - 'csrf_protection' => array( - 'enabled' => true, + 'form' => array( + 'csrf_protection' => array( + 'enabled' => true, + ), ), )); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_sets_field_name.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_sets_field_name.php index 3022ffc986..56fdea36e1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_sets_field_name.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_sets_field_name.php @@ -1,12 +1,12 @@ loadFromExtension('framework', array( - 'csrf_protection' => array( - 'enabled' => true, - 'field_name' => '_custom', - ), 'form' => array( 'enabled' => true, + 'field_name' => '_custom', + 'csrf_protection' => array( + 'enabled' => true, + ), ), 'session' => array( 'handler_id' => null, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_under_form_sets_field_name.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_under_form_sets_field_name.php index e3d13b4f92..3198fa20db 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_under_form_sets_field_name.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_csrf_under_form_sets_field_name.php @@ -1,10 +1,6 @@ loadFromExtension('framework', array( - 'csrf_protection' => array( - 'enabled' => true, - 'field_name' => '_custom', - ), 'form' => array( 'enabled' => true, 'csrf_protection' => array( diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php index f5716ddd31..d205a5661d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -5,14 +5,12 @@ $container->loadFromExtension('framework', array( 'default_locale' => 'fr', 'form' => array( 'csrf_protection' => array( + 'enabled' => true, 'field_name' => '_csrf', ), ), 'http_method_override' => false, 'trusted_proxies' => array('127.0.0.1', '10.0.0.1'), - 'csrf_protection' => array( - 'enabled' => true, - ), 'esi' => array( 'enabled' => true, ), diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml index 4484c353ed..7fe196f3a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml @@ -7,8 +7,6 @@ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.xml index 635557f938..5024dcc794 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.xml @@ -7,6 +7,8 @@ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.xml index 0a08d2351a..065796efda 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.xml @@ -7,6 +7,8 @@ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml index 8e1803a6c7..bf83fb0f31 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml @@ -7,8 +7,9 @@ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - - + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml index d08ac9e542..0668e999db 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml @@ -7,7 +7,6 @@ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 797e691559..d23c89644c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -7,9 +7,8 @@ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml deleted file mode 100644 index 963848f767..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - php - http://cdn.example.com - - http://images1.example.com - http://images2.example.com - - - - https://bar2.example.com - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_url_package.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_url_package.xml deleted file mode 100644 index 0fd2039b07..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_url_package.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - php - twig - https://cdn.example.com - - https://images.example.com - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml index c08db90f5b..5743e15760 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml @@ -1,8 +1,5 @@ framework: - csrf_protection: false secret: s3cr3t form: csrf_protection: true session: ~ - # CSRF is disabled by default - # csrf_protection: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_disabled.yml index b094cc481f..439c59144f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_disabled.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_disabled.yml @@ -1,2 +1,3 @@ framework: - csrf_protection: false + form: + csrf_protection: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml index b8065b6fb6..207bb09859 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml @@ -1,2 +1,3 @@ framework: - csrf_protection: ~ + form: + csrf_protection: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_sets_field_name.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_sets_field_name.yml deleted file mode 100644 index 3347cbfaf1..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_sets_field_name.yml +++ /dev/null @@ -1,5 +0,0 @@ -framework: - csrf_protection: - field_name: _custom - form: ~ - session: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_under_form_sets_field_name.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_under_form_sets_field_name.yml index a4bb34259f..f88192da25 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_under_form_sets_field_name.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_under_form_sets_field_name.yml @@ -1,6 +1,4 @@ framework: - csrf_protection: - field_name: _custom form: csrf_protection: field_name: _custom_form diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index 493817881f..d86c9712bb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -6,8 +6,6 @@ framework: field_name: _csrf http_method_override: false trusted_proxies: ['127.0.0.1', '10.0.0.1'] - csrf_protection: - enabled: true esi: enabled: true profiler: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 1f2f80d41b..5b1fa8c30e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -308,20 +308,6 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]); } - /** - * @group legacy - */ - public function testLegacyFullyConfiguredValidationService() - { - if (!extension_loaded('apc')) { - $this->markTestSkipped('The apc extension is not available.'); - } - - $container = $this->createContainerFromFile('full'); - - $this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator')); - } - public function testValidationService() { $container = $this->createContainerFromFile('validation_annotations'); @@ -409,28 +395,6 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertFalse($container->getParameter('form.type_extension.csrf.enabled')); } - /** - * @group legacy - */ - public function testLegacyFormCsrfFieldNameCanBeSetUnderCsrfSettings() - { - $container = $this->createContainerFromFile('form_csrf_sets_field_name'); - - $this->assertTrue($container->getParameter('form.type_extension.csrf.enabled')); - $this->assertEquals('_custom', $container->getParameter('form.type_extension.csrf.field_name')); - } - - /** - * @group legacy - */ - public function testLegacyFormCsrfFieldNameUnderFormSettingsTakesPrecedence() - { - $container = $this->createContainerFromFile('form_csrf_under_form_sets_field_name'); - - $this->assertTrue($container->getParameter('form.type_extension.csrf.enabled')); - $this->assertEquals('_custom_form', $container->getParameter('form.type_extension.csrf.field_name')); - } - public function testStopwatchEnabledWithDebugModeEnabled() { $container = $this->createContainerFromFile('default_config', array( diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php deleted file mode 100644 index 1757cfee96..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Fragment; - -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Bundle\FrameworkBundle\Fragment\ContainerAwareHIncludeFragmentRenderer; -use Symfony\Component\HttpFoundation\Request; - -/** - * @group legacy - */ -class LegacyContainerAwareHIncludeFragmentRendererTest extends TestCase -{ - public function testRender() - { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $container->expects($this->once()) - ->method('get') - ->will($this->returnValue($this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock())) - ; - $renderer = new ContainerAwareHIncludeFragmentRenderer($container); - $renderer->render('/', Request::create('/')); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml index 07b4d0c9e4..a3251d6c4b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml @@ -1,10 +1,10 @@ framework: secret: test - csrf_protection: - enabled: true router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" } validation: { enabled: true, enable_annotations: true } - form: ~ + form: + csrf_protection: + enabled: true test: ~ default_locale: en session: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php index 48a7737dd8..5c00c62e7f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php @@ -26,18 +26,6 @@ class GlobalVariablesTest extends TestCase $this->globals = new GlobalVariables($this->container); } - /** - * @group legacy - */ - public function testLegacyGetSecurity() - { - $securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); - - $this->assertNull($this->globals->getSecurity()); - $this->container->set('security.context', $securityContext); - $this->assertSame($securityContext, $this->globals->getSecurity()); - } - public function testGetUserNoTokenStorage() { $this->assertNull($this->globals->getUser()); diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml index c503dd0354..1aa92c54f4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml @@ -10,11 +10,6 @@ - - - - - diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index 72a41bc122..cf2f561503 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -40,24 +40,6 @@ class SecurityDataCollectorTest extends \PHPUnit_Framework_TestCase $this->assertEmpty($collector->getUser()); } - /** - * @group legacy - */ - public function testLegacyCollectWhenAuthenticationTokenIsNull() - { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); - $collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy()); - $collector->collect($this->getRequest(), $this->getResponse()); - - $this->assertTrue($collector->isEnabled()); - $this->assertFalse($collector->isAuthenticated()); - $this->assertNull($collector->getTokenClass()); - $this->assertTrue($collector->supportsRoleHierarchy()); - $this->assertCount(0, $collector->getRoles()); - $this->assertCount(0, $collector->getInheritedRoles()); - $this->assertEmpty($collector->getUser()); - } - /** @dataProvider provideRoles */ public function testCollectAuthenticationTokenAndRoles(array $roles, array $normalizedRoles, array $inheritedRoles) { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml index 8077dd146c..6c228cfb7a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml @@ -1,10 +1,10 @@ framework: secret: test - csrf_protection: - enabled: true router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" } validation: { enabled: true, enable_annotations: true } - form: ~ + form: + csrf_protection: + enabled: true test: ~ default_locale: en session: diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml index 43961a1aeb..3e86d72a1a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml @@ -1,11 +1,11 @@ framework: secret: test - csrf_protection: - enabled: true router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" } validation: { enabled: true, enable_annotations: true } assets: ~ - form: ~ + form: + csrf_protection: + enabled: true test: ~ default_locale: en session: