Skip to content

Commit 76c3508

Browse files
Merge branch '2.3' into 2.5
* 2.3: [SecurityBundle] Firewall providers building - code cleaning [Filesystem] symlink use RealPath instead LinkTarget Fixed the AuthenticationProviderInterface alignment Fixed the proxy-manager version constraint Conflicts: composer.json src/Symfony/Bridge/ProxyManager/composer.json
2 parents 1cd4d48 + 39a3379 commit 76c3508

File tree

7 files changed

+84
-30
lines changed

7 files changed

+84
-30
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"monolog/monolog": "~1.3",
7373
"propel/propel1": "~1.6",
7474
"ircmaxell/password-compat": "~1.0",
75-
"ocramius/proxy-manager": ">=0.3.1,<0.6-dev",
75+
"ocramius/proxy-manager": "~0.3.1",
7676
"egulias/email-validator": "~1.2"
7777
},
7878
"autoload": {

src/Symfony/Bridge/ProxyManager/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.3.3",
2020
"symfony/dependency-injection": "~2.3",
21-
"ocramius/proxy-manager": ">=0.3.1,<0.6-dev"
21+
"ocramius/proxy-manager": "~0.3.1"
2222
},
2323
"require-dev": {
2424
"symfony/config": "~2.3"

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

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

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

@@ -537,37 +538,12 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
537538

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

554543
return $name;
555544
}
556545

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

573549
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+
}

src/Symfony/Bundle/SecurityBundle/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();

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
408408
}
409409
} else {
410410
if (is_link($file)) {
411-
$this->symlink($file->getLinkTarget(), $target);
411+
$this->symlink($file->getRealPath(), $target);
412412
} elseif (is_dir($file)) {
413413
$this->mkdir($target);
414414
} elseif (is_file($file)) {

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,31 @@ public function testMirrorCopiesLinkedDirectoryContents()
853853
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
854854
}
855855

856+
public function testMirrorCopiesRelativeLinkedContents()
857+
{
858+
$this->markAsSkippedIfSymlinkIsMissing();
859+
860+
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
861+
$oldPath = getcwd();
862+
863+
mkdir($sourcePath.'nested/', 0777, true);
864+
file_put_contents($sourcePath.'/nested/file1.txt', 'FILE1');
865+
// Note: Create relative symlink
866+
chdir($sourcePath);
867+
symlink('nested', 'link1');
868+
869+
chdir($oldPath);
870+
871+
$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;
872+
873+
$this->filesystem->mirror($sourcePath, $targetPath);
874+
875+
$this->assertTrue(is_dir($targetPath));
876+
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
877+
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
878+
$this->assertEquals($sourcePath.'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
879+
}
880+
856881
/**
857882
* @dataProvider providePathsForIsAbsolutePath
858883
*/

0 commit comments

Comments
 (0)