Skip to content

Commit 21a05de

Browse files
committed
feature #33507 [WebProfiler] Deprecated intercept_redirects in 4.4 (dorumd)
This PR was squashed before being merged into the 4.4 branch (closes #33507). Discussion ---------- [WebProfiler] Deprecated intercept_redirects in 4.4 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #33467 | License | MIT | Doc PR | - Deprecated `web_profiler.intercept_redirects` config option in symfony 4.4. Commits ------- 514c736 [WebProfiler] Deprecated intercept_redirects in 4.4
2 parents 24faadc + 514c736 commit 21a05de

File tree

6 files changed

+142
-16
lines changed

6 files changed

+142
-16
lines changed

UPGRADE-4.4.md

+2
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ WebProfilerBundle
323323

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

327329
WebServerBundle
328330
---------------

UPGRADE-5.0.md

+2
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,8 @@ WebProfilerBundle
577577

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

581583
Workflow
582584
--------

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ CHANGELOG
1212
* deprecated the `ExceptionController` in favor of `ExceptionPanelController`
1313
* marked all classes of the WebProfilerBundle as internal
1414
* added a section with the stamps of a message after it is dispatched in the Messenger panel
15+
* deprecated the `web_profiler.intercept_redirects` config option,
16+
toolbar for the redirected resource contains a link to the redirect response profile instead.
1517

1618
4.3.0
1719
-----

src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getConfigTreeBuilder()
3636
$treeBuilder->getRootNode()
3737
->children()
3838
->booleanNode('toolbar')->defaultFalse()->end()
39-
->booleanNode('intercept_redirects')->defaultFalse()->end()
39+
->booleanNode('intercept_redirects')->defaultFalse()->setDeprecated('The "intercept_redirects" option is deprecated since version 4.4 and will be removed in 5.0.')->end()
4040
->scalarNode('excluded_ajax_paths')->defaultValue('^/((index|app(_[\w]+)?)\.php/)?_wdt')->end()
4141
->end()
4242
;

src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php

+62-7
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,78 @@ class ConfigurationTest extends TestCase
2020
/**
2121
* @dataProvider getDebugModes
2222
*/
23-
public function testConfigTree($options, $results)
23+
public function testConfigTree(array $options, array $expectedResult)
2424
{
2525
$processor = new Processor();
2626
$configuration = new Configuration();
2727
$config = $processor->processConfiguration($configuration, [$options]);
2828

29-
$this->assertEquals($results, $config);
29+
$this->assertEquals($expectedResult, $config);
3030
}
3131

3232
public function getDebugModes()
3333
{
3434
return [
35-
[[], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
36-
[['intercept_redirects' => true], ['intercept_redirects' => true, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
37-
[['intercept_redirects' => false], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
38-
[['toolbar' => true], ['intercept_redirects' => false, 'toolbar' => true, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
39-
[['excluded_ajax_paths' => 'test'], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => 'test']],
35+
[
36+
'options' => [],
37+
'expectedResult' => [
38+
'intercept_redirects' => false,
39+
'toolbar' => false,
40+
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
41+
],
42+
],
43+
[
44+
'options' => ['toolbar' => true],
45+
'expectedResult' => [
46+
'intercept_redirects' => false,
47+
'toolbar' => true,
48+
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
49+
],
50+
],
51+
[
52+
'options' => ['excluded_ajax_paths' => 'test'],
53+
'expectedResult' => [
54+
'intercept_redirects' => false,
55+
'toolbar' => false,
56+
'excluded_ajax_paths' => 'test',
57+
],
58+
],
59+
];
60+
}
61+
62+
/**
63+
* @group legacy
64+
*
65+
* @dataProvider getInterceptRedirectsConfiguration
66+
*/
67+
public function testConfigTreeUsingInterceptRedirects(bool $interceptRedirects, array $expectedResult)
68+
{
69+
$processor = new Processor();
70+
$configuration = new Configuration();
71+
$config = $processor->processConfiguration($configuration, [['intercept_redirects' => $interceptRedirects]]);
72+
73+
$this->assertEquals($expectedResult, $config);
74+
}
75+
76+
public function getInterceptRedirectsConfiguration()
77+
{
78+
return [
79+
[
80+
'interceptRedirects' => true,
81+
'expectedResult' => [
82+
'intercept_redirects' => true,
83+
'toolbar' => false,
84+
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
85+
],
86+
],
87+
[
88+
'interceptRedirects' => false,
89+
'expectedResult' => [
90+
'intercept_redirects' => false,
91+
'toolbar' => false,
92+
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
93+
],
94+
],
4095
];
4196
}
4297
}

src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php

+73-8
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,21 @@ public function testDefaultConfig($debug)
9999
self::assertSaneContainer($this->getCompiledContainer());
100100
}
101101

102+
public function getDebugModes()
103+
{
104+
return [
105+
['debug' => false],
106+
['debug' => true],
107+
];
108+
}
109+
102110
/**
103-
* @dataProvider getDebugModes
111+
* @dataProvider getToolbarConfig
104112
*/
105-
public function testToolbarConfig($toolbarEnabled, $interceptRedirects, $listenerInjected, $listenerEnabled)
113+
public function testToolbarConfig(bool $toolbarEnabled, bool $listenerInjected, bool $listenerEnabled)
106114
{
107115
$extension = new WebProfilerExtension();
108-
$extension->load([['toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects]], $this->container);
116+
$extension->load([['toolbar' => $toolbarEnabled]], $this->container);
109117
$this->container->removeDefinition('web_profiler.controller.exception');
110118

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

120-
public function getDebugModes()
128+
public function getToolbarConfig()
129+
{
130+
return [
131+
[
132+
'toolbarEnabled' => false,
133+
'listenerInjected' => false,
134+
'listenerEnabled' => false,
135+
],
136+
[
137+
'toolbarEnabled' => true,
138+
'listenerInjected' => true,
139+
'listenerEnabled' => true,
140+
],
141+
];
142+
}
143+
144+
/**
145+
* @group legacy
146+
*
147+
* @dataProvider getInterceptRedirectsToolbarConfig
148+
*/
149+
public function testToolbarConfigUsingInterceptRedirects(
150+
bool $toolbarEnabled,
151+
bool $interceptRedirects,
152+
bool $listenerInjected,
153+
bool $listenerEnabled
154+
) {
155+
$extension = new WebProfilerExtension();
156+
$extension->load(
157+
[['toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects]],
158+
$this->container
159+
);
160+
$this->container->removeDefinition('web_profiler.controller.exception');
161+
162+
$this->assertSame($listenerInjected, $this->container->has('web_profiler.debug_toolbar'));
163+
164+
self::assertSaneContainer($this->getCompiledContainer(), '', ['web_profiler.csp.handler']);
165+
166+
if ($listenerInjected) {
167+
$this->assertSame($listenerEnabled, $this->container->get('web_profiler.debug_toolbar')->isEnabled());
168+
}
169+
}
170+
171+
public function getInterceptRedirectsToolbarConfig()
121172
{
122173
return [
123-
[false, false, false, false],
124-
[true, false, true, true],
125-
[false, true, true, false],
126-
[true, true, true, true],
174+
[
175+
'toolbarEnabled' => false,
176+
'interceptRedirects' => true,
177+
'listenerInjected' => true,
178+
'listenerEnabled' => false,
179+
],
180+
[
181+
'toolbarEnabled' => false,
182+
'interceptRedirects' => false,
183+
'listenerInjected' => false,
184+
'listenerEnabled' => false,
185+
],
186+
[
187+
'toolbarEnabled' => true,
188+
'interceptRedirects' => true,
189+
'listenerInjected' => true,
190+
'listenerEnabled' => true,
191+
],
127192
];
128193
}
129194

0 commit comments

Comments
 (0)