Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7183be3

Browse filesBrowse files
committed
bug #23049 [FrameworkBundle] mitigate BC break with empty trusted_proxies (xabbuh)
This PR was merged into the 3.3 branch. Discussion ---------- [FrameworkBundle] mitigate BC break with empty trusted_proxies | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | kind of | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22238 (comment) | License | MIT | Doc PR | Commits ------- ff055ef mitigate BC break with empty trusted_proxies
2 parents 8d58b50 + ff055ef commit 7183be3
Copy full SHA for 7183be3

File tree

2 files changed

+37
-1
lines changed
Filter options

2 files changed

+37
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ public function getConfigTreeBuilder()
6767
->end()
6868
->arrayNode('trusted_proxies') // @deprecated in version 3.3, to be removed in 4.0
6969
->beforeNormalization()
70-
->always()
70+
->ifTrue(function ($v) { return empty($v); })
71+
->then(function () { @trigger_error('The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.', E_USER_DEPRECATED); })
72+
->end()
73+
->beforeNormalization()
74+
->ifTrue(function ($v) { return !empty($v); })
7175
->thenInvalid('The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.')
7276
->end()
7377
->end()

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,38 @@ public function testDoNoDuplicateDefaultFormResources()
4343
$this->assertEquals(array('FrameworkBundle:Form'), $config['templating']['form']['resources']);
4444
}
4545

46+
/**
47+
* @group legacy
48+
* @expectedDeprecation The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.
49+
*/
50+
public function testTrustedProxiesSetToNullIsDeprecated()
51+
{
52+
$processor = new Processor();
53+
$configuration = new Configuration(true);
54+
$processor->processConfiguration($configuration, array(array('trusted_proxies' => null)));
55+
}
56+
57+
/**
58+
* @group legacy
59+
* @expectedDeprecation The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.
60+
*/
61+
public function testTrustedProxiesSetToEmptyArrayIsDeprecated()
62+
{
63+
$processor = new Processor();
64+
$configuration = new Configuration(true);
65+
$processor->processConfiguration($configuration, array(array('trusted_proxies' => array())));
66+
}
67+
68+
/**
69+
* @expectedException \InvalidArgumentException
70+
*/
71+
public function testTrustedProxiesSetToNonEmptyArrayIsInvalid()
72+
{
73+
$processor = new Processor();
74+
$configuration = new Configuration(true);
75+
$processor->processConfiguration($configuration, array(array('trusted_proxies' => array('127.0.0.1'))));
76+
}
77+
4678
public function testAssetsCanBeEnabled()
4779
{
4880
$processor = new Processor();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.