Skip to content

[WebProfiler] Deprecated intercept_redirects in 4.4 #33507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UPGRADE-4.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ WebProfilerBundle

* Deprecated the `ExceptionController` class in favor of `ExceptionErrorController`
* Deprecated the `TemplateManager::templateExists()` method
* Deprecated the `web_profiler.intercept_redirects` config option,
toolbar for the redirected resource contains a link to the redirect response profile instead.

WebServerBundle
---------------
Expand Down
2 changes: 2 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ WebProfilerBundle

* Removed the `ExceptionController::templateExists()` method
* Removed the `TemplateManager::templateExists()` method
* Removed the `web_profiler.intercept_redirects` config option,
toolbar for the redirected resource contains a link to the redirect response profile instead.

Workflow
--------
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ CHANGELOG
* deprecated the `ExceptionController` in favor of `ExceptionPanelController`
* marked all classes of the WebProfilerBundle as internal
* added a section with the stamps of a message after it is dispatched in the Messenger panel
* deprecated the `web_profiler.intercept_redirects` config option,
toolbar for the redirected resource contains a link to the redirect response profile instead.

4.3.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getConfigTreeBuilder()
$treeBuilder->getRootNode()
->children()
->booleanNode('toolbar')->defaultFalse()->end()
->booleanNode('intercept_redirects')->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()
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,78 @@ class ConfigurationTest extends TestCase
/**
* @dataProvider getDebugModes
*/
public function testConfigTree($options, $results)
public function testConfigTree(array $options, array $expectedResult)
{
$processor = new Processor();
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, [$options]);

$this->assertEquals($results, $config);
$this->assertEquals($expectedResult, $config);
}

public function getDebugModes()
{
return [
[[], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
[['intercept_redirects' => true], ['intercept_redirects' => true, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
[['intercept_redirects' => false], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
[['toolbar' => true], ['intercept_redirects' => false, 'toolbar' => true, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
[['excluded_ajax_paths' => 'test'], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => 'test']],
[
'options' => [],
'expectedResult' => [
'intercept_redirects' => false,
'toolbar' => false,
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
],
],
[
'options' => ['toolbar' => true],
'expectedResult' => [
'intercept_redirects' => false,
'toolbar' => true,
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
],
],
[
'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',
],
],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,21 @@ public function testDefaultConfig($debug)
self::assertSaneContainer($this->getCompiledContainer());
}

public function getDebugModes()
{
return [
['debug' => false],
['debug' => true],
];
}

/**
* @dataProvider getDebugModes
* @dataProvider getToolbarConfig
*/
public function testToolbarConfig($toolbarEnabled, $interceptRedirects, $listenerInjected, $listenerEnabled)
public function testToolbarConfig(bool $toolbarEnabled, bool $listenerInjected, bool $listenerEnabled)
{
$extension = new WebProfilerExtension();
$extension->load([['toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects]], $this->container);
$extension->load([['toolbar' => $toolbarEnabled]], $this->container);
$this->container->removeDefinition('web_profiler.controller.exception');

$this->assertSame($listenerInjected, $this->container->has('web_profiler.debug_toolbar'));
Expand All @@ -117,13 +125,70 @@ public function testToolbarConfig($toolbarEnabled, $interceptRedirects, $listene
}
}

public function getDebugModes()
public function getToolbarConfig()
{
return [
[
'toolbarEnabled' => false,
'listenerInjected' => false,
'listenerEnabled' => false,
],
[
'toolbarEnabled' => true,
'listenerInjected' => true,
'listenerEnabled' => true,
],
];
}

/**
* @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 [
[false, false, false, false],
[true, false, true, true],
[false, true, true, false],
[true, true, true, true],
[
'toolbarEnabled' => false,
'interceptRedirects' => true,
'listenerInjected' => true,
'listenerEnabled' => false,
],
[
'toolbarEnabled' => false,
'interceptRedirects' => false,
'listenerInjected' => false,
'listenerEnabled' => false,
],
[
'toolbarEnabled' => true,
'interceptRedirects' => true,
'listenerInjected' => true,
'listenerEnabled' => true,
],
];
}

Expand Down