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 67cb63a

Browse filesBrowse files
committed
Remove deprecate session service
1 parent 1cec4a5 commit 67cb63a
Copy full SHA for 67cb63a

File tree

Expand file treeCollapse file tree

27 files changed

+42
-456
lines changed
Filter options
Expand file treeCollapse file tree

27 files changed

+42
-456
lines changed

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

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

4+
6.0
5+
---
6+
7+
* Remove the `session.storage` alias and `session.storage.*` services, use the `session.storage.factory` alias and `session.storage.factory.*` services instead
8+
* Remove `framework.session.storage_id` configuration option, use the `framework.session.storage_factory_id` configuration option instead
9+
* Remove the `session` service and the `SessionInterface` alias, use the `\Symfony\Component\HttpFoundation\Request::getSession()` or the new `\Symfony\Component\HttpFoundation\RequestStack::getSession()` methods instead
10+
* Remove the `session.attribute_bag` service and `session.flash_bag` service
11+
412
5.3
513
---
614

‎src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public static function getSubscribedServices()
9494
'request_stack' => '?'.RequestStack::class,
9595
'http_kernel' => '?'.HttpKernelInterface::class,
9696
'serializer' => '?'.SerializerInterface::class,
97-
'session' => '?'.SessionInterface::class,
9897
'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class,
9998
'twig' => '?'.Environment::class,
10099
'doctrine' => '?'.ManagerRegistry::class,

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SessionPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SessionPass.php
-72Lines changed: 0 additions & 72 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+1-8Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -612,15 +612,8 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
612612
->arrayNode('session')
613613
->info('session configuration')
614614
->canBeEnabled()
615-
->beforeNormalization()
616-
->ifTrue(function ($v) {
617-
return \is_array($v) && isset($v['storage_id']) && isset($v['storage_factory_id']);
618-
})
619-
->thenInvalid('You cannot use both "storage_id" and "storage_factory_id" at the same time under "framework.session"')
620-
->end()
621615
->children()
622-
->scalarNode('storage_id')->defaultValue('session.storage.native')->end()
623-
->scalarNode('storage_factory_id')->defaultNull()->end()
616+
->scalarNode('storage_factory_id')->defaultValue('session.storage.factory.native')->end()
624617
->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
625618
->scalarNode('name')
626619
->validate()

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+5-32Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
use Symfony\Component\HttpClient\RetryableHttpClient;
7373
use Symfony\Component\HttpClient\ScopingHttpClient;
7474
use Symfony\Component\HttpFoundation\Request;
75-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
7675
use Symfony\Component\HttpKernel\Attribute\AsController;
7776
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
7877
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
@@ -1048,20 +1047,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
10481047
$loader->load('session.php');
10491048

10501049
// session storage
1051-
if (null === $config['storage_factory_id']) {
1052-
trigger_deprecation('symfony/framework-bundle', '5.3', 'Not setting the "framework.session.storage_factory_id" configuration option is deprecated, it will default to "session.storage.factory.native" and will replace the "framework.session.storage_id" configuration option in version 6.0.');
1053-
$container->setAlias('session.storage', $config['storage_id']);
1054-
$container->setAlias('session.storage.factory', 'session.storage.factory.service');
1055-
} else {
1056-
$container->setAlias('session.storage.factory', $config['storage_factory_id']);
1057-
1058-
$container->removeAlias(SessionStorageInterface::class);
1059-
$container->removeDefinition('session.storage.metadata_bag');
1060-
$container->removeDefinition('session.storage.native');
1061-
$container->removeDefinition('session.storage.php_bridge');
1062-
$container->removeDefinition('session.storage.mock_file');
1063-
$container->removeAlias('session.storage.filesystem');
1064-
}
1050+
$container->setAlias('session.storage.factory', $config['storage_factory_id']);
10651051

10661052
$options = ['cache_limiter' => '0'];
10671053
foreach (['name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'cookie_samesite', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor', 'sid_length', 'sid_bits_per_character'] as $key) {
@@ -1071,30 +1057,17 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
10711057
}
10721058

10731059
if ('auto' === ($options['cookie_secure'] ?? null)) {
1074-
if (null === $config['storage_factory_id']) {
1075-
$locator = $container->getDefinition('session_listener')->getArgument(0);
1076-
$locator->setValues($locator->getValues() + [
1077-
'session_storage' => new Reference('session.storage', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
1078-
'request_stack' => new Reference('request_stack'),
1079-
]);
1080-
} else {
1081-
$container->getDefinition('session.storage.factory.native')->replaceArgument(3, true);
1082-
$container->getDefinition('session.storage.factory.php_bridge')->replaceArgument(2, true);
1083-
}
1060+
$container->getDefinition('session.storage.factory.native')->replaceArgument(3, true);
1061+
$container->getDefinition('session.storage.factory.php_bridge')->replaceArgument(2, true);
10841062
}
10851063

10861064
$container->setParameter('session.storage.options', $options);
10871065

10881066
// session handler (the internal callback registered with PHP session management)
10891067
if (null === $config['handler_id']) {
10901068
// Set the handler class to be null
1091-
if ($container->hasDefinition('session.storage.native')) {
1092-
$container->getDefinition('session.storage.native')->replaceArgument(1, null);
1093-
$container->getDefinition('session.storage.php_bridge')->replaceArgument(0, null);
1094-
} else {
1095-
$container->getDefinition('session.storage.factory.native')->replaceArgument(1, null);
1096-
$container->getDefinition('session.storage.factory.php_bridge')->replaceArgument(0, null);
1097-
}
1069+
$container->getDefinition('session.storage.factory.native')->replaceArgument(1, null);
1070+
$container->getDefinition('session.storage.factory.php_bridge')->replaceArgument(0, null);
10981071

10991072
$container->setAlias('session.handler', 'session.handler.native_file');
11001073
} else {

‎src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
2121
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
2222
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RemoveUnusedSessionMarshallingHandlerPass;
23-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SessionPass;
2423
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass;
2524
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass;
2625
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
@@ -159,7 +158,6 @@ public function build(ContainerBuilder $container)
159158
$container->addCompilerPass(new RegisterReverseContainerPass(true));
160159
$container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING);
161160
$container->addCompilerPass(new RemoveUnusedSessionMarshallingHandlerPass());
162-
$container->addCompilerPass(new SessionPass());
163161

164162
if ($container->getParameter('kernel.debug')) {
165163
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2);

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/session.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/session.php
+1-70Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,23 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14-
use Symfony\Bundle\FrameworkBundle\Session\DeprecatedSessionFactory;
15-
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
16-
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
17-
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
18-
use Symfony\Component\HttpFoundation\Session\Session;
1914
use Symfony\Component\HttpFoundation\Session\SessionFactory;
20-
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2115
use Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler;
2216
use Symfony\Component\HttpFoundation\Session\Storage\Handler\IdentityMarshaller;
2317
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MarshallingSessionHandler;
2418
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
2519
use Symfony\Component\HttpFoundation\Session\Storage\Handler\SessionHandlerFactory;
2620
use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler;
2721
use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag;
28-
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
2922
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorageFactory;
30-
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
3123
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorageFactory;
32-
use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
3324
use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorageFactory;
34-
use Symfony\Component\HttpFoundation\Session\Storage\ServiceSessionFactory;
35-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
3625
use Symfony\Component\HttpKernel\EventListener\SessionListener;
3726

3827
return static function (ContainerConfigurator $container) {
3928
$container->parameters()->set('session.metadata.storage_key', '_sf2_meta');
4029

4130
$container->services()
42-
->set('.session.do-not-use', Session::class) // to be removed in 6.0
43-
->factory([service('session.factory'), 'createSession'])
4431
->set('session.factory', SessionFactory::class)
4532
->args([
4633
service('request_stack'),
@@ -79,60 +66,9 @@
7966
param('session.metadata.update_threshold'),
8067
]),
8168
])
82-
->set('session.storage.factory.service', ServiceSessionFactory::class)
83-
->args([
84-
service('session.storage'),
85-
])
86-
->deprecate('symfony/framework-bundle', '5.3', 'The "%service_id%" service is deprecated, use "session.storage.factory.native", "session.storage.factory.php_bridge" or "session.storage.factory.mock_file" instead.')
8769

88-
->set('.session.deprecated', SessionInterface::class) // to be removed in 6.0
89-
->factory([inline_service(DeprecatedSessionFactory::class)->args([service('request_stack')]), 'getSession'])
90-
->alias(SessionInterface::class, '.session.do-not-use')
91-
->deprecate('symfony/framework-bundle', '5.3', 'The "%alias_id%" and "SessionInterface" aliases are deprecated, use "$requestStack->getSession()" instead.')
92-
->alias(SessionStorageInterface::class, 'session.storage')
93-
->deprecate('symfony/framework-bundle', '5.3', 'The "%alias_id%" alias is deprecated, use "session.storage.factory" instead.')
9470
->alias(\SessionHandlerInterface::class, 'session.handler')
9571

96-
->set('session.storage.metadata_bag', MetadataBag::class)
97-
->args([
98-
param('session.metadata.storage_key'),
99-
param('session.metadata.update_threshold'),
100-
])
101-
->deprecate('symfony/framework-bundle', '5.3', 'The "%service_id%" service is deprecated, create your own "session.storage.factory" instead.')
102-
103-
->set('session.storage.native', NativeSessionStorage::class)
104-
->args([
105-
param('session.storage.options'),
106-
service('session.handler'),
107-
service('session.storage.metadata_bag'),
108-
])
109-
->deprecate('symfony/framework-bundle', '5.3', 'The "%service_id%" service is deprecated, use "session.storage.factory.native" instead.')
110-
111-
->set('session.storage.php_bridge', PhpBridgeSessionStorage::class)
112-
->args([
113-
service('session.handler'),
114-
service('session.storage.metadata_bag'),
115-
])
116-
->deprecate('symfony/framework-bundle', '5.3', 'The "%service_id%" service is deprecated, use "session.storage.factory.php_bridge" instead.')
117-
118-
->set('session.flash_bag', FlashBag::class)
119-
->factory([service('.session.do-not-use'), 'getFlashBag'])
120-
->deprecate('symfony/framework-bundle', '5.1', 'The "%service_id%" service is deprecated, use "$session->getFlashBag()" instead.')
121-
->alias(FlashBagInterface::class, 'session.flash_bag')
122-
123-
->set('session.attribute_bag', AttributeBag::class)
124-
->factory([service('.session.do-not-use'), 'getBag'])
125-
->args(['attributes'])
126-
->deprecate('symfony/framework-bundle', '5.1', 'The "%service_id%" service is deprecated, use "$session->getAttributeBag()" instead.')
127-
128-
->set('session.storage.mock_file', MockFileSessionStorage::class)
129-
->args([
130-
param('kernel.cache_dir').'/sessions',
131-
'MOCKSESSID',
132-
service('session.storage.metadata_bag'),
133-
])
134-
->deprecate('symfony/framework-bundle', '5.3', 'The "%service_id%" service is deprecated, use "session.storage.factory.mock_file" instead.')
135-
13672
->set('session.handler.native_file', StrictSessionHandler::class)
13773
->args([
13874
inline_service(NativeFileSessionHandler::class)
@@ -146,19 +82,14 @@
14682
->set('session_listener', SessionListener::class)
14783
->args([
14884
service_locator([
149-
'session' => service('.session.do-not-use')->ignoreOnInvalid(),
150-
'initialized_session' => service('.session.do-not-use')->ignoreOnUninitialized(),
85+
'session_factory' => service('session.factory'),
15186
'logger' => service('logger')->ignoreOnInvalid(),
15287
'session_collector' => service('data_collector.request.session_collector')->ignoreOnInvalid(),
15388
]),
15489
param('kernel.debug'),
15590
])
15691
->tag('kernel.event_subscriber')
15792

158-
// for BC
159-
->alias('session.storage.filesystem', 'session.storage.mock_file')
160-
->deprecate('symfony/framework-bundle', '5.3', 'The "%alias_id%" alias is deprecated, use "session.storage.factory.mock_file" instead.')
161-
16293
->set('session.marshaller', IdentityMarshaller::class)
16394

16495
->set('session.marshalling_handler', MarshallingSessionHandler::class)

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/test.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/test.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@
3636
->set('test.client.cookiejar', CookieJar::class)->share(false)
3737

3838
->set('test.session.listener', TestSessionListener::class)
39-
->args([
40-
service_locator([
41-
'session' => service('.session.do-not-use')->ignoreOnInvalid(),
42-
]),
43-
])
39+
->args([service_locator([])])
4440
->tag('kernel.event_subscriber')
4541

4642
->set('test.service_container', TestContainer::class)

‎src/Symfony/Bundle/FrameworkBundle/Session/DeprecatedSessionFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Session/DeprecatedSessionFactory.php
-46Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

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