Merge branch '2.8' into 3.1
* 2.8: [travis] Use 7.0 until 7.1 is fixed [DIC] Fix service autowiring inheritance [SecurityBundle] Add missing deprecation notice for form_login.intention Verify explicitly that the request IP is a valid IPv4 address
This commit is contained in:
commit
298a680ea0
|
@ -28,7 +28,7 @@ matrix:
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: deps=high
|
env: deps=high
|
||||||
- php: 7.1
|
- php: 7.0
|
||||||
env: deps=low
|
env: deps=low
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ class ResolveDefinitionTemplatesPass implements CompilerPassInterface
|
||||||
$def->setFile($parentDef->getFile());
|
$def->setFile($parentDef->getFile());
|
||||||
$def->setPublic($parentDef->isPublic());
|
$def->setPublic($parentDef->isPublic());
|
||||||
$def->setLazy($parentDef->isLazy());
|
$def->setLazy($parentDef->isLazy());
|
||||||
|
$def->setAutowired($parentDef->isAutowired());
|
||||||
|
|
||||||
// overwrite with values specified in the decorator
|
// overwrite with values specified in the decorator
|
||||||
$changes = $definition->getChanges();
|
$changes = $definition->getChanges();
|
||||||
|
@ -151,6 +152,9 @@ class ResolveDefinitionTemplatesPass implements CompilerPassInterface
|
||||||
if (isset($changes['deprecated'])) {
|
if (isset($changes['deprecated'])) {
|
||||||
$def->setDeprecated($definition->isDeprecated(), $definition->getDeprecationMessage('%service_id%'));
|
$def->setDeprecated($definition->isDeprecated(), $definition->getDeprecationMessage('%service_id%'));
|
||||||
}
|
}
|
||||||
|
if (isset($changes['autowire'])) {
|
||||||
|
$def->setAutowired($definition->isAutowired());
|
||||||
|
}
|
||||||
if (isset($changes['decorated_service'])) {
|
if (isset($changes['decorated_service'])) {
|
||||||
$decoratedService = $definition->getDecoratedService();
|
$decoratedService = $definition->getDecoratedService();
|
||||||
if (null === $decoratedService) {
|
if (null === $decoratedService) {
|
||||||
|
|
|
@ -134,6 +134,16 @@ class DefinitionDecorator extends Definition
|
||||||
return parent::setDeprecated($boolean, $template);
|
return parent::setDeprecated($boolean, $template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function setAutowired($autowired)
|
||||||
|
{
|
||||||
|
$this->changes['autowire'] = true;
|
||||||
|
|
||||||
|
return parent::setAutowired($autowired);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an argument to pass to the service constructor/factory method.
|
* Gets an argument to pass to the service constructor/factory method.
|
||||||
*
|
*
|
||||||
|
|
|
@ -210,6 +210,36 @@ class ResolveDefinitionTemplatesPassTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertTrue($container->getDefinition('child1')->isLazy());
|
$this->assertTrue($container->getDefinition('child1')->isLazy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetAutowiredOnServiceHasParent()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$container->register('parent', 'stdClass');
|
||||||
|
|
||||||
|
$container->setDefinition('child1', new DefinitionDecorator('parent'))
|
||||||
|
->setAutowired(true)
|
||||||
|
;
|
||||||
|
|
||||||
|
$this->process($container);
|
||||||
|
|
||||||
|
$this->assertTrue($container->getDefinition('child1')->isAutowired());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetAutowiredOnServiceIsParent()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$container->register('parent', 'stdClass')
|
||||||
|
->setAutowired(true)
|
||||||
|
;
|
||||||
|
|
||||||
|
$container->setDefinition('child1', new DefinitionDecorator('parent'));
|
||||||
|
|
||||||
|
$this->process($container);
|
||||||
|
|
||||||
|
$this->assertTrue($container->getDefinition('child1')->isAutowired());
|
||||||
|
}
|
||||||
|
|
||||||
public function testDeepDefinitionsResolving()
|
public function testDeepDefinitionsResolving()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
|
@ -69,6 +69,16 @@ class DefinitionDecoratorTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(array('lazy' => true), $def->getChanges());
|
$this->assertEquals(array('lazy' => true), $def->getChanges());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetAutowired()
|
||||||
|
{
|
||||||
|
$def = new DefinitionDecorator('foo');
|
||||||
|
|
||||||
|
$this->assertFalse($def->isAutowired());
|
||||||
|
$this->assertSame($def, $def->setAutowired(false));
|
||||||
|
$this->assertFalse($def->isAutowired());
|
||||||
|
$this->assertEquals(array('autowire' => true), $def->getChanges());
|
||||||
|
}
|
||||||
|
|
||||||
public function testSetArgument()
|
public function testSetArgument()
|
||||||
{
|
{
|
||||||
$def = new DefinitionDecorator('foo');
|
$def = new DefinitionDecorator('foo');
|
||||||
|
|
|
@ -61,11 +61,14 @@ class IpUtils
|
||||||
*/
|
*/
|
||||||
public static function checkIp4($requestIp, $ip)
|
public static function checkIp4($requestIp, $ip)
|
||||||
{
|
{
|
||||||
|
if (!filter_var($requestIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (false !== strpos($ip, '/')) {
|
if (false !== strpos($ip, '/')) {
|
||||||
list($address, $netmask) = explode('/', $ip, 2);
|
list($address, $netmask) = explode('/', $ip, 2);
|
||||||
|
|
||||||
if ($netmask === '0') {
|
if ($netmask === '0') {
|
||||||
// Ensure IP is valid - using ip2long below implicitly validates, but we need to do it manually here
|
|
||||||
return filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
return filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ class IpUtilsTest extends \PHPUnit_Framework_TestCase
|
||||||
array(true, '1.2.3.4', '0.0.0.0/0'),
|
array(true, '1.2.3.4', '0.0.0.0/0'),
|
||||||
array(true, '1.2.3.4', '192.168.1.0/0'),
|
array(true, '1.2.3.4', '192.168.1.0/0'),
|
||||||
array(false, '1.2.3.4', '256.256.256/0'), // invalid CIDR notation
|
array(false, '1.2.3.4', '256.256.256/0'), // invalid CIDR notation
|
||||||
|
array(false, 'an_invalid_ip', '192.168.1.0/24'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue