From 32ceea69b06573a238f4adb44bbf352d2c7d2c1c Mon Sep 17 00:00:00 2001 From: Dorel Mardari Date: Tue, 17 Sep 2019 10:27:00 +0200 Subject: [PATCH] [WebProfiler] Removed intercept_redirects config option --- .../DependencyInjection/Configuration.php | 1 - .../WebProfilerExtension.php | 5 +- .../EventListener/WebDebugToolbarListener.php | 16 +----- .../Resources/config/toolbar.xml | 1 - .../DependencyInjection/ConfigurationTest.php | 39 -------------- .../WebProfilerExtensionTest.php | 51 ------------------- 6 files changed, 3 insertions(+), 110 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php index 303208f6062cd..fad172100cefe 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php @@ -36,7 +36,6 @@ public function getConfigTreeBuilder() $treeBuilder->getRootNode() ->children() ->booleanNode('toolbar')->defaultFalse()->end() - ->booleanNode('intercept_redirects')->defaultFalse()->setDeprecated('The "intercept_redirects" option is deprecated since version 4.4 and will be removed in 5.0.')->end() ->scalarNode('excluded_ajax_paths')->defaultValue('^/((index|app(_[\w]+)?)\.php/)?_wdt')->end() ->end() ; diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php index 5d2be199094d0..bee403b4a9392 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php @@ -46,10 +46,9 @@ public function load(array $configs, ContainerBuilder $container) $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('profiler.xml'); - if ($config['toolbar'] || $config['intercept_redirects']) { + if ($config['toolbar']) { $loader->load('toolbar.xml'); - $container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(4, $config['excluded_ajax_paths']); - $container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']); + $container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(3, $config['excluded_ajax_paths']); $container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index e960d9b38bf40..54f5ff21dfe2d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -15,7 +15,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag; use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -40,16 +39,14 @@ class WebDebugToolbarListener implements EventSubscriberInterface protected $twig; protected $urlGenerator; - protected $interceptRedirects; protected $mode; protected $excludedAjaxPaths; private $cspHandler; - public function __construct(Environment $twig, bool $interceptRedirects = false, int $mode = self::ENABLED, UrlGeneratorInterface $urlGenerator = null, string $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null) + public function __construct(Environment $twig, int $mode = self::ENABLED, UrlGeneratorInterface $urlGenerator = null, string $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null) { $this->twig = $twig; $this->urlGenerator = $urlGenerator; - $this->interceptRedirects = $interceptRedirects; $this->mode = $mode; $this->excludedAjaxPaths = $excludedAjaxPaths; $this->cspHandler = $cspHandler; @@ -87,17 +84,6 @@ public function onKernelResponse(ResponseEvent $event) return; } - if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat()) { - if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { - // keep current flashes for one more request if using AutoExpireFlashBag - $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); - } - - $response->setContent($this->twig->render('@WebProfiler/Profiler/toolbar_redirect.html.twig', ['location' => $response->headers->get('Location')])); - $response->setStatusCode(200); - $response->headers->remove('Location'); - } - if (self::DISABLED === $this->mode || !$response->headers->has('X-Debug-Token') || $response->isRedirection() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml index c38db2056c1a4..640dbb2a5578b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml @@ -10,7 +10,6 @@ - %web_profiler.debug_toolbar.intercept_redirects% %web_profiler.debug_toolbar.mode% diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php index 06aa85aee360a..a65ccf803cdcf 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -35,7 +35,6 @@ public function getDebugModes() [ 'options' => [], 'expectedResult' => [ - 'intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt', ], @@ -43,7 +42,6 @@ public function getDebugModes() [ 'options' => ['toolbar' => true], 'expectedResult' => [ - 'intercept_redirects' => false, 'toolbar' => true, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt', ], @@ -51,47 +49,10 @@ public function getDebugModes() [ 'options' => ['excluded_ajax_paths' => 'test'], 'expectedResult' => [ - 'intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => 'test', ], ], ]; } - - /** - * @group legacy - * - * @dataProvider getInterceptRedirectsConfiguration - */ - public function testConfigTreeUsingInterceptRedirects(bool $interceptRedirects, array $expectedResult) - { - $processor = new Processor(); - $configuration = new Configuration(); - $config = $processor->processConfiguration($configuration, [['intercept_redirects' => $interceptRedirects]]); - - $this->assertEquals($expectedResult, $config); - } - - public function getInterceptRedirectsConfiguration() - { - return [ - [ - 'interceptRedirects' => true, - 'expectedResult' => [ - 'intercept_redirects' => true, - 'toolbar' => false, - 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt', - ], - ], - [ - 'interceptRedirects' => false, - 'expectedResult' => [ - 'intercept_redirects' => false, - 'toolbar' => false, - 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt', - ], - ], - ]; - } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index 9934077cf1aac..1d7f191d1e338 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -141,57 +141,6 @@ public function getToolbarConfig() ]; } - /** - * @group legacy - * - * @dataProvider getInterceptRedirectsToolbarConfig - */ - public function testToolbarConfigUsingInterceptRedirects( - bool $toolbarEnabled, - bool $interceptRedirects, - bool $listenerInjected, - bool $listenerEnabled - ) { - $extension = new WebProfilerExtension(); - $extension->load( - [['toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects]], - $this->container - ); - $this->container->removeDefinition('web_profiler.controller.exception'); - - $this->assertSame($listenerInjected, $this->container->has('web_profiler.debug_toolbar')); - - self::assertSaneContainer($this->getCompiledContainer(), '', ['web_profiler.csp.handler']); - - if ($listenerInjected) { - $this->assertSame($listenerEnabled, $this->container->get('web_profiler.debug_toolbar')->isEnabled()); - } - } - - public function getInterceptRedirectsToolbarConfig() - { - return [ - [ - 'toolbarEnabled' => false, - 'interceptRedirects' => true, - 'listenerInjected' => true, - 'listenerEnabled' => false, - ], - [ - 'toolbarEnabled' => false, - 'interceptRedirects' => false, - 'listenerInjected' => false, - 'listenerEnabled' => false, - ], - [ - 'toolbarEnabled' => true, - 'interceptRedirects' => true, - 'listenerInjected' => true, - 'listenerEnabled' => true, - ], - ]; - } - private function getCompiledContainer() { if ($this->container->has('web_profiler.debug_toolbar')) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy