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 3cfa0c7

Browse filesBrowse files
committed
Revert "feature #21792 [Security] deprecate multiple providers in context listener (xabbuh)"
This reverts commit 924c1f0, reversing changes made to afff0ce.
1 parent e0568d8 commit 3cfa0c7
Copy full SHA for 3cfa0c7

File tree

6 files changed

+10
-38
lines changed
Filter options

6 files changed

+10
-38
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ Process
105105
Security
106106
--------
107107

108-
* Deprecated the ability to pass multiple user providers to the `ContextListener`. Pass only the user provider responsible
109-
for the active firewall instead.
110-
111108
* The `RoleInterface` has been deprecated. Extend the `Symfony\Component\Security\Core\Role\Role`
112109
class in your custom role implementations instead.
113110

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,6 @@ Process
261261
Security
262262
--------
263263

264-
* Dropped support for passing multiple user providers to the `ContextListener`. Pass only the user provider responsible
265-
for the active firewall instead.
266-
267264
* The `RoleInterface` has been removed. Extend the `Symfony\Component\Security\Core\Role\Role`
268265
class instead.
269266

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ private function createContextListener($container, $contextKey, $providerId)
434434

435435
$listenerId = 'security.context_listener.'.count($this->contextListeners);
436436
$listener = $container->setDefinition($listenerId, new ChildDefinition('security.context_listener'));
437-
$listener->replaceArgument(1, new Reference($providerId));
437+
$listener->replaceArgument(1, array(new Reference($providerId)));
438438
$listener->replaceArgument(2, $contextKey);
439439

440440
return $this->contextListeners[$contextKey] = $listenerId;

‎src/Symfony/Component/Security/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/CHANGELOG.md
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
CHANGELOG
22
=========
33

4-
3.3.0
5-
-----
6-
7-
* Deprecated the ability to pass multiple user providers to the `ContextListener`. Pass only the user provider responsible
8-
for the active firewall instead.
9-
104
3.2.0
115
-----
126

‎src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/ContextListener.php
+1-15Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,12 @@ class ContextListener implements ListenerInterface
4444
private $registered;
4545
private $trustResolver;
4646

47-
/**
48-
* @param TokenStorageInterface $tokenStorage
49-
* @param UserProviderInterface|UserProviderInterface[] $userProviders
50-
* @param string $contextKey
51-
* @param LoggerInterface|null $logger
52-
* @param EventDispatcherInterface|null $dispatcher
53-
* @param AuthenticationTrustResolverInterface|null $trustResolver
54-
*/
55-
public function __construct(TokenStorageInterface $tokenStorage, $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, AuthenticationTrustResolverInterface $trustResolver = null)
47+
public function __construct(TokenStorageInterface $tokenStorage, array $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, AuthenticationTrustResolverInterface $trustResolver = null)
5648
{
5749
if (empty($contextKey)) {
5850
throw new \InvalidArgumentException('$contextKey must not be empty.');
5951
}
6052

61-
if (is_array($userProviders)) {
62-
@trigger_error(sprintf('Being able to pass multiple user providers to the constructor of %s is deprecated since version 3.3 and will not be supported anymore in 4.0. Only pass the user provider for the current firewall context instead.', __CLASS__), E_USER_DEPRECATED);
63-
} else {
64-
$userProviders = array($userProviders);
65-
}
66-
6753
foreach ($userProviders as $userProvider) {
6854
if (!$userProvider instanceof UserProviderInterface) {
6955
throw new \InvalidArgumentException(sprintf('User provider "%s" must implement "Symfony\Component\Security\Core\User\UserProviderInterface".', get_class($userProvider)));

‎src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
2323
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
2424
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
25-
use Symfony\Component\Security\Core\User\UserProviderInterface;
2625
use Symfony\Component\Security\Http\Firewall\ContextListener;
2726
use Symfony\Component\EventDispatcher\EventDispatcher;
2827

@@ -36,13 +35,12 @@ public function testItRequiresContextKey()
3635
{
3736
new ContextListener(
3837
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(),
39-
$this->getMockBuilder(UserProviderInterface::class)->getMock(),
38+
array(),
4039
''
4140
);
4241
}
4342

4443
/**
45-
* @group legacy
4644
* @expectedException \InvalidArgumentException
4745
* @expectedExceptionMessage User provider "stdClass" must implement "Symfony\Component\Security\Core\User\UserProviderInterface
4846
*/
@@ -111,7 +109,7 @@ public function testOnKernelResponseWithoutSession()
111109
new Response()
112110
);
113111

114-
$listener = new ContextListener($tokenStorage, $this->getMockBuilder(UserProviderInterface::class)->getMock(), 'session', null, new EventDispatcher());
112+
$listener = new ContextListener($tokenStorage, array(), 'session', null, new EventDispatcher());
115113
$listener->onKernelResponse($event);
116114

117115
$this->assertTrue($session->isStarted());
@@ -130,7 +128,7 @@ public function testOnKernelResponseWithoutSessionNorToken()
130128
new Response()
131129
);
132130

133-
$listener = new ContextListener(new TokenStorage(), $this->getMockBuilder(UserProviderInterface::class)->getMock(), 'session', null, new EventDispatcher());
131+
$listener = new ContextListener(new TokenStorage(), array(), 'session', null, new EventDispatcher());
134132
$listener->onKernelResponse($event);
135133

136134
$this->assertFalse($session->isStarted());
@@ -165,7 +163,7 @@ public function testInvalidTokenInSession($token)
165163
->method('setToken')
166164
->with(null);
167165

168-
$listener = new ContextListener($tokenStorage, $this->getMockBuilder(UserProviderInterface::class)->getMock(), 'key123');
166+
$listener = new ContextListener($tokenStorage, array(), 'key123');
169167
$listener->handle($event);
170168
}
171169

@@ -186,7 +184,7 @@ public function testHandleAddsKernelResponseListener()
186184
->disableOriginalConstructor()
187185
->getMock();
188186

189-
$listener = new ContextListener($tokenStorage, $this->getMockBuilder(UserProviderInterface::class)->getMock(), 'key123', null, $dispatcher);
187+
$listener = new ContextListener($tokenStorage, array(), 'key123', null, $dispatcher);
190188

191189
$event->expects($this->any())
192190
->method('isMasterRequest')
@@ -210,7 +208,7 @@ public function testOnKernelResponseListenerRemovesItself()
210208
->disableOriginalConstructor()
211209
->getMock();
212210

213-
$listener = new ContextListener($tokenStorage, $this->getMockBuilder(UserProviderInterface::class)->getMock(), 'key123', null, $dispatcher);
211+
$listener = new ContextListener($tokenStorage, array(), 'key123', null, $dispatcher);
214212

215213
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
216214
$request->expects($this->any())
@@ -244,7 +242,7 @@ public function testHandleRemovesTokenIfNoPreviousSessionWasFound()
244242
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
245243
$tokenStorage->expects($this->once())->method('setToken')->with(null);
246244

247-
$listener = new ContextListener($tokenStorage, $this->getMockBuilder(UserProviderInterface::class)->getMock(), 'key123');
245+
$listener = new ContextListener($tokenStorage, array(), 'key123');
248246
$listener->handle($event);
249247
}
250248

@@ -270,7 +268,7 @@ protected function runSessionOnKernelResponse($newToken, $original = null)
270268
new Response()
271269
);
272270

273-
$listener = new ContextListener($tokenStorage, $this->getMockBuilder(UserProviderInterface::class)->getMock(), 'session', null, new EventDispatcher());
271+
$listener = new ContextListener($tokenStorage, array(), 'session', null, new EventDispatcher());
274272
$listener->onKernelResponse($event);
275273

276274
return $session;

0 commit comments

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