mitigate BC break with empty trusted_proxies

This commit is contained in:
Christian Flothmann 2017-06-03 12:01:46 +02:00
parent d0aa4d93dd
commit ff055ef7f3
2 changed files with 37 additions and 1 deletions

View File

@ -67,7 +67,11 @@ class Configuration implements ConfigurationInterface
->end()
->arrayNode('trusted_proxies') // @deprecated in version 3.3, to be removed in 4.0
->beforeNormalization()
->always()
->ifTrue(function ($v) { return empty($v); })
->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); })
->end()
->beforeNormalization()
->ifTrue(function ($v) { return !empty($v); })
->thenInvalid('The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.')
->end()
->end()

View File

@ -43,6 +43,38 @@ class ConfigurationTest extends TestCase
$this->assertEquals(array('FrameworkBundle:Form'), $config['templating']['form']['resources']);
}
/**
* @group legacy
* @expectedDeprecation The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.
*/
public function testTrustedProxiesSetToNullIsDeprecated()
{
$processor = new Processor();
$configuration = new Configuration(true);
$processor->processConfiguration($configuration, array(array('trusted_proxies' => null)));
}
/**
* @group legacy
* @expectedDeprecation The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.
*/
public function testTrustedProxiesSetToEmptyArrayIsDeprecated()
{
$processor = new Processor();
$configuration = new Configuration(true);
$processor->processConfiguration($configuration, array(array('trusted_proxies' => array())));
}
/**
* @expectedException \InvalidArgumentException
*/
public function testTrustedProxiesSetToNonEmptyArrayIsInvalid()
{
$processor = new Processor();
$configuration = new Configuration(true);
$processor->processConfiguration($configuration, array(array('trusted_proxies' => array('127.0.0.1'))));
}
public function testAssetsCanBeEnabled()
{
$processor = new Processor();