Skip to content

Commit 7707b84

Browse files
Merge branch '2.5' into 2.6
* 2.5: [Form] fixed a maxlength overring on a guessing [Debug] Show only unique class candidates [SecurityBundle] Firewall providers building - code cleaning [Filesystem] symlink use RealPath instead LinkTarget [DependencyInjection] Remove duplicate declaration in PhpDumper terminals are not interactive on Travis Revert "[DependencyInjection] backport perf optim" [WebProfilerBundle] replaced pattern to path attribute in routes definitions. fix phpdoc's alignment Fixed the AuthenticationProviderInterface alignment Fixed the proxy-manager version constraint [FrameworkBundle][Template name] avoid error message for the shortcut notation. [DependencyInjection] perf optim: call dirname() at most 5x [DependencyInjection] backport perf optim Fixed #12845 adding a listener to an event that is currently being dispatched will not result into a fatal error in TraceableEventDispatcher [EventDispatcher] [2.5] Remove possible call_user_func() [2.3] Remove possible call_user_func() Conflicts: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
2 parents 8aece75 + 027d4f0 commit 7707b84

File tree

4 files changed

+58
-28
lines changed

4 files changed

+58
-28
lines changed

DependencyInjection/SecurityExtension.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
513513
{
514514
$name = $this->getUserProviderId(strtolower($name));
515515

516+
// Doctrine Entity and In-memory DAO provider are managed by factories
516517
foreach ($this->userProviderFactories as $factory) {
517518
$key = str_replace('-', '_', $factory->getKey());
518519

@@ -539,37 +540,12 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
539540

540541
$container
541542
->setDefinition($name, new DefinitionDecorator('security.user.provider.chain'))
542-
->addArgument($providers)
543-
;
544-
545-
return $name;
546-
}
547-
548-
// Doctrine Entity DAO provider
549-
if (isset($provider['entity'])) {
550-
$container
551-
->setDefinition($name, new DefinitionDecorator('security.user.provider.entity'))
552-
->addArgument($provider['entity']['class'])
553-
->addArgument($provider['entity']['property'])
554-
;
543+
->addArgument($providers);
555544

556545
return $name;
557546
}
558547

559-
// In-memory DAO provider
560-
$definition = $container->setDefinition($name, new DefinitionDecorator('security.user.provider.in_memory'));
561-
foreach ($provider['users'] as $username => $user) {
562-
$userId = $name.'_'.$username;
563-
564-
$container
565-
->setDefinition($userId, new DefinitionDecorator('security.user.provider.in_memory.user'))
566-
->setArguments(array($username, (string) $user['password'], $user['roles']))
567-
;
568-
569-
$definition->addMethodCall('createUser', array(new Reference($userId)));
570-
}
571-
572-
return $name;
548+
throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name));
573549
}
574550

575551
private function getUserProviderId($name)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider;
4+
5+
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
6+
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
9+
class DummyProvider implements UserProviderFactoryInterface
10+
{
11+
public function create(ContainerBuilder $container, $id, $config)
12+
{
13+
14+
}
15+
16+
public function getKey()
17+
{
18+
return 'foo';
19+
}
20+
21+
public function addConfiguration(NodeDefinition $node)
22+
{
23+
24+
}
25+
}

Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
1515
use Symfony\Bundle\SecurityBundle\SecurityBundle;
16+
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718

1819
class SecurityExtensionTest extends \PHPUnit_Framework_TestCase
@@ -66,6 +67,33 @@ public function testFirewallWithoutAuthenticationListener()
6667
$container->compile();
6768
}
6869

70+
/**
71+
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
72+
* @expectedExceptionMessage Unable to create definition for "security.user.provider.concrete.my_foo" user provider
73+
*/
74+
public function testFirewallWithInvalidUserProvider()
75+
{
76+
$container = $this->getRawContainer();
77+
78+
$extension = $container->getExtension('security');
79+
$extension->addUserProviderFactory(new DummyProvider());
80+
81+
$container->loadFromExtension('security', array(
82+
'providers' => array(
83+
'my_foo' => array('foo' => []),
84+
),
85+
86+
'firewalls' => array(
87+
'some_firewall' => array(
88+
'pattern' => '/.*',
89+
'http_basic' => [],
90+
),
91+
),
92+
));
93+
94+
$container->compile();
95+
}
96+
6997
protected function getRawContainer()
7098
{
7199
$container = new ContainerBuilder();

Tests/Functional/app/AppKernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ public function serialize()
105105

106106
public function unserialize($str)
107107
{
108-
call_user_func_array(array($this, '__construct'), unserialize($str));
108+
$a = unserialize($str);
109+
$this->__construct($a[0], $a[1], $a[2], $a[3]);
109110
}
110111

111112
protected function getKernelParameters()

0 commit comments

Comments
 (0)