Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit9de1f9b

Browse files
committed
Remove deprecate session service
1 parent1cec4a5 commit9de1f9b

File tree

28 files changed

+53
-468
lines changed

28 files changed

+53
-468
lines changed

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

Lines 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‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
useSymfony\Component\HttpFoundation\RequestStack;
3030
useSymfony\Component\HttpFoundation\Response;
3131
useSymfony\Component\HttpFoundation\ResponseHeaderBag;
32-
useSymfony\Component\HttpFoundation\Session\SessionInterface;
3332
useSymfony\Component\HttpFoundation\StreamedResponse;
3433
useSymfony\Component\HttpKernel\Exception\NotFoundHttpException;
3534
useSymfony\Component\HttpKernel\HttpKernelInterface;
@@ -94,7 +93,6 @@ public static function getSubscribedServices()
9493
'request_stack' =>'?'.RequestStack::class,
9594
'http_kernel' =>'?'.HttpKernelInterface::class,
9695
'serializer' =>'?'.SerializerInterface::class,
97-
'session' =>'?'.SessionInterface::class,
9896
'security.authorization_checker' =>'?'.AuthorizationCheckerInterface::class,
9997
'twig' =>'?'.Environment::class,
10098
'doctrine' =>'?'.ManagerRegistry::class,

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

Lines changed: 0 additions & 72 deletions
This file was deleted.

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

Lines 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‎

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
useSymfony\Component\HttpClient\RetryableHttpClient;
7373
useSymfony\Component\HttpClient\ScopingHttpClient;
7474
useSymfony\Component\HttpFoundation\Request;
75-
useSymfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
7675
useSymfony\Component\HttpKernel\Attribute\AsController;
7776
useSymfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
7877
useSymfony\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' =>newReference('session.storage', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
1078-
'request_stack' =>newReference('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‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
2121
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
2222
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RemoveUnusedSessionMarshallingHandlerPass;
23-
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SessionPass;
2423
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass;
2524
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass;
2625
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
@@ -159,7 +158,6 @@ public function build(ContainerBuilder $container)
159158
$container->addCompilerPass(newRegisterReverseContainerPass(true));
160159
$container->addCompilerPass(newRegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING);
161160
$container->addCompilerPass(newRemoveUnusedSessionMarshallingHandlerPass());
162-
$container->addCompilerPass(newSessionPass());
163161

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

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

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,23 @@
1111

1212
namespaceSymfony\Component\DependencyInjection\Loader\Configurator;
1313

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

3827
returnstaticfunction (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‎

Lines 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‎

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp