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 991e062

Browse filesBrowse files
committed
feature #21451 [SecurityBundle] Lazy load request matchers in FirewallMap (chalasr)
This PR was merged into the 3.3-dev branch. Discussion ---------- [SecurityBundle] Lazy load request matchers in FirewallMap | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 5b72cf6 [Security] Lazy load request matchers
2 parents 00ab4b3 + 5b72cf6 commit 991e062
Copy full SHA for 991e062

File tree

7 files changed

+99
-8
lines changed
Filter options

7 files changed

+99
-8
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ SecurityBundle
5858
* The `FirewallContext::getContext()` method has been deprecated and will be removed in 4.0.
5959
Use the `getListeners()` method instead.
6060

61+
* The `FirewallMap::$map` and `$container` properties have been deprecated and will be removed in 4.0.
62+
6163
TwigBridge
6264
----------
6365

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ SecurityBundle
164164

165165
* The `FirewallContext::getContext()` method has been removed, use the `getListeners()` method instead.
166166

167+
* The `FirewallMap::$map` and `$container` properties have been removed.
168+
167169
HttpFoundation
168170
---------------
169171

‎src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

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

4+
3.3.0
5+
-----
6+
7+
* Deprecated the `FirewallMap::$map` and `$container` properties.
8+
49
3.2.0
510
-----
611

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
1616
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1717
use Symfony\Component\DependencyInjection\Alias;
18+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1819
use Symfony\Component\DependencyInjection\ChildDefinition;
1920
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2021
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@@ -255,7 +256,7 @@ private function createFirewalls($config, ContainerBuilder $container)
255256

256257
$map[$contextId] = $matcher;
257258
}
258-
$mapDef->replaceArgument(1, $map);
259+
$mapDef->replaceArgument(1, new IteratorArgument($map));
259260

260261
// add authentication providers to authentication manager
261262
$authenticationProviders = array_map(function ($id) {

‎src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105

106106
<service id="security.firewall.map" class="Symfony\Bundle\SecurityBundle\Security\FirewallMap" public="false">
107107
<argument type="service" id="service_container" />
108-
<argument type="collection" />
108+
<argument />
109109
</service>
110110

111111
<service id="security.firewall.context" class="Symfony\Bundle\SecurityBundle\Security\FirewallContext" abstract="true">

‎src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php
+85-4Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,94 @@
2222
*
2323
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
2424
*/
25-
class FirewallMap implements FirewallMapInterface
25+
class FirewallMap extends _FirewallMap implements FirewallMapInterface
2626
{
27-
protected $container;
28-
protected $map;
27+
/**
28+
* @deprecated since version 3.3, to be removed in 4.0 alongside with magic methods below
29+
*/
30+
private $container;
31+
32+
/**
33+
* @deprecated since version 3.3, to be removed in 4.0 alongside with magic methods below
34+
*/
35+
private $map;
36+
37+
public function __construct(ContainerInterface $container, $map)
38+
{
39+
parent::__construct($container, $map);
40+
$this->container = $container;
41+
$this->map = $map;
42+
}
43+
44+
/**
45+
* @internal
46+
*/
47+
public function __get($name)
48+
{
49+
if ('map' === $name || 'container' === $name) {
50+
@trigger_error(sprintf('Using the "%s::$%s" property is deprecated since version 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED);
51+
52+
if ('map' === $name && $this->map instanceof \Traversable) {
53+
$this->map = iterator_to_array($this->map);
54+
}
55+
}
56+
57+
return $this->$name;
58+
}
59+
60+
/**
61+
* @internal
62+
*/
63+
public function __set($name, $value)
64+
{
65+
if ('map' === $name || 'container' === $name) {
66+
@trigger_error(sprintf('Using the "%s::$%s" property is deprecated since version 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED);
67+
68+
$set = \Closure::bind(function ($name, $value) { $this->$name = $value; }, $this, parent::class);
69+
$set($name, $value);
70+
}
71+
72+
$this->$name = $value;
73+
}
74+
75+
/**
76+
* @internal
77+
*/
78+
public function __isset($name)
79+
{
80+
if ('map' === $name || 'container' === $name) {
81+
@trigger_error(sprintf('Using the "%s::$%s" property is deprecated since version 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED);
82+
}
83+
84+
return isset($this->$name);
85+
}
86+
87+
/**
88+
* @internal
89+
*/
90+
public function __unset($name)
91+
{
92+
if ('map' === $name || 'container' === $name) {
93+
@trigger_error(sprintf('Using the "%s::$%s" property is deprecated since version 3.3 as it will be removed/private in 4.0.', __CLASS__, $name), E_USER_DEPRECATED);
94+
95+
$unset = \Closure::bind(function ($name) { unset($this->$name); }, $this, parent::class);
96+
$unset($name);
97+
}
98+
99+
unset($this->$name);
100+
}
101+
}
102+
103+
/**
104+
* @internal to be removed in 4.0
105+
*/
106+
class _FirewallMap
107+
{
108+
private $container;
109+
private $map;
29110
private $contexts;
30111

31-
public function __construct(ContainerInterface $container, array $map)
112+
public function __construct(ContainerInterface $container, $map)
32113
{
33114
$this->container = $container;
34115
$this->map = $map;

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testFirewalls()
6868
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
6969
$listeners = array();
7070
$configs = array();
71-
foreach (array_keys($arguments[1]) as $contextId) {
71+
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
7272
$contextDef = $container->getDefinition($contextId);
7373
$arguments = $contextDef->getArguments();
7474
$listeners[] = array_map(function ($ref) { return (string) $ref; }, $arguments['index_0']);
@@ -180,7 +180,7 @@ public function testFirewallRequestMatchers()
180180
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
181181
$matchers = array();
182182

183-
foreach ($arguments[1] as $reference) {
183+
foreach ($arguments[1]->getValues() as $reference) {
184184
if ($reference instanceof Reference) {
185185
$definition = $container->getDefinition((string) $reference);
186186
$matchers[] = $definition->getArguments();

0 commit comments

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