8000 [FrameworkBundle] Add session.handler service and handler_id configur… · symfony/symfony@a1c678e · GitHub
[go: up one dir, main page]

Skip to content

Commit a1c678e

Browse files
author
Drak
committed
[FrameworkBundle] Add session.handler service and handler_id configuration property.
Revert service back to session.storage.native Rename session.storage.native_file to session.handler.native_file (which is the default so no BC break from 2.0)
1 parent 1308312 commit a1c678e

14 files changed

+35
-17
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
167167
->canBeUnset()
168168
->children()
169169
->booleanNode('auto_start')->defaultFalse()->end()
170-
->scalarNode('storage_id')->defaultValue('session.storage.native_file')->end()
170+
->scalarNode('storage_id')->defaultValue('session.storage.native')->end()
171+
->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
171172
->scalarNode('name')->end()
172173
->scalarNode('cookie_lifetime')->end()
173174
->scalarNode('cookie_path')->end()

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,16 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
310310
}
311311
$container->setParameter('session.storage.options', $options);
312312

313+
// session handler (the internal callback registered with PHP session management)
314+
$container->setAlias('session.handler', $config['handler_id']);
315+
313316
$this->addClassesToCompile(array(
314317
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
315318
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface',
316-
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\AbstractSessionStorage',
319+
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorage',
320+
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\NativeSessionHandler',
321+
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\AbstractProxy',
322+
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\SessionHandlerProxy',
317323
$container->getDefinition('session')->getClass(),
318324
));
319325

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474

7575
<xsd:complexType name="session">
7676
<xsd:attribute name="storage-id" type="xsd:string" />
77+
<xsd:attribute name="handler-id" type="xsd:string" />
7778
<xsd:attribute name="name" type="xsd:string" />
7879
<xsd:attribute name="cookie-lifetime" type="xsd:integer" />
7980
<xsd:attribute name="cookie-path" type="xsd:string" />

src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
<parameter key="session.class">Symfony\Component\HttpFoundation\Session\Session</parameter>
99
<parameter key="session.flashbag.class">Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag</parameter>
1010
<parameter key="session.attribute_bag.class">Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag</parameter>
11-
<parameter key="session.storage.native_file.class">Symfony\Component\HttpFoundation\Session\Storage\NativeFileSessionStorage</parameter>
11+
<parameter key="session.storage.native.class">Symfony\Component\HttpFoundation\Session\Storage\SessionStorage</parameter>
1212
<parameter key="session.storage.mock_file.class">Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage</parameter>
13+
<parameter key="session.handler.native_file.class">Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler</parameter>
1314
<parameter key="session_listener.class">Symfony\Bundle\FrameworkBundle\EventListener\SessionListener</parameter>
1415
</parameters>
1516

@@ -20,18 +21,21 @@
2021
<argument type="service" id="session.flash_bag" />
2122
</service>
2223

24+
<service id="session.storage.native" class="%session.storage.native.class%">
25+
<argument>%session.storage.options%</argument>
26+
<argument type="service" id="session.handler" />
27+
</service>
28+
2329
<service id="session.flash_bag" class="%session.flashbag.class%" public="false" />
2430

2531
<service id="session.attribute_bag" class="%session.attribute_bag.class%" public="false" />
2632

2733
<service id="session.storage.mock_file" class="%session.storage.mock_file.class%" public="false">
2834
<argument>%kernel.cache_dir%/sessions</argument>
29-
<argument>%session.storage.options%</argument>
3035
</service>
3136

32-
<service id="session.storage.native_file" class="%session.storage.native_file.class%" public="false">
37+
<service id="session.handler.native_file" class="%session.handler.native_file.class%" public="false">
3338
<argument>%kernel.cache_dir%/sessions</argument>
34-
<argument>%session.storage.options%</argument>
3539
</service>
3640

3741
<service id="session_listener" class="%session_listener.class%">
@@ -40,7 +44,6 @@
4044
</service>
4145

4246
<!-- for BC -->
43-
<service id="session.storage.native" alias="session.storage.native_file" />
4447
<service id="session.storage.filesystem" alias="session.storage.mock_file" />
4548
</services>
4649
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/deprecated_merge_full.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
'secret' => 's3cr3t',
55
'session' => array(
66
'auto_start' => true,
7-
'storage_id' => 'session.storage.native_file',
7+
'storage_id' => 'session.storage.native',
8+
'handler_id' => 'session.handler.native_file',
89
'name' => '_SYMFONY',
910
'lifetime' => 2012,
1011
'path' => '/sf2',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/deprecated_merge_partial.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
'secret' => 's3cr3t',
55
'session' => array(
66
'auto_start' => true,
7-
'storage_id' => 'session.storage.native_file',
7+
'storage_id' => 'session.storage.native',
8+
'handler_id' => 'session.handler.native_file',
89
'name' => '_SYMFONY',
910
'lifetime' => 2012,
1011
'path' => '/sf2',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
),
2121
'session' => array(
2222
'auto_start' => true,
23-
'storage_id' => 'session.storage.native_file',
23+
'storage_id' => 'session.storage.native',
24+
'handler_id' => 'session.handler.native_file',
2425
'name' => '_SYMFONY',
2526
'lifetime' => 86400,
2627
'path' => '/',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/deprecated_merge_full.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
88

99
<framework:config secret="s3cr3t">
10-
<framework:session auto-start="true" storage-id="session.storage.native_file" name="_SYMFONY" lifetime="2012" path="/sf2" domain="sf2.example.com" secure="false" httponly="false" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
10+
<framework:session auto-start="true" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" lifetime="2012" path="/sf2" domain="sf2.example.com" secure="false" httponly="false" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
1111
</framework:config>
1212
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/deprecated_merge_partial.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
88

99
<framework:config secret="s3cr3t">
10-
<framework:session auto-start="true" storage-id="session.storage.native_file" name="_SYMFONY" lifetime="2012" path="/sf2" domain="sf2.example.com" secure="false" httponly="false" cookie-lifetime="86400" cookie-path="/" cookie-httponly="true" />
10+
<framework:session auto-start="true" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" lifetime="2012" path="/sf2" domain="sf2.example.com" secure="false" httponly="false" cookie-lifetime="86400" cookie-path="/" cookie-httponly="true" />
1111
</framework:config>
1212
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<framework:esi enabled="true" />
1313
<framework:profiler only-exceptions="true" />
1414
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
15-
<framework:session auto-start="true" storage-id="session.storage.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
15+
<framework:session auto-start="true" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
1616
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
1717
<framework:loader>loader.foo</framework:loader>
1818
<framework:loader>loader.bar</framework:loader>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/deprecated_merge_full.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ framework:
22
secret: s3cr3t
33
session:
44
auto_start: true
5-
storage_id: session.storage.native_file
5+
storage_id: session.storage.native
6+
handler_id: session.handler.native_file
67
name: _SYMFONY
78
lifetime: 2012
89
path: /sf2

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/deprecated_merge_partial.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ framework:
22
secret: s3cr3t
33
session:
44
auto_start: true
5-
storage_id: session.storage.native_file
5+
storage_id: session.storage.native
6+
handler_id: session.handler.native_file
67
name: _SYMFONY
78
lifetime: 2012
89
path: /sf2

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ framework:
1414
type: xml
1515
session:
1616
auto_start: true
17-
storage_id: session.storage.native_file
17+
storage_id: session.storage.native
18+
handler_id: session.handler.native_file
1819
name: _SYMFONY
1920
lifetime: 86400
2021
path: /

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public function testSession()
7878
$this->assertTrue($container->hasDefinition('session'), '->registerSessionConfiguration() loads session.xml');
7979
$this->assertEquals('fr', $container->getParameter('kernel.default_locale'));
8080
$this->assertTrue($container->getDefinition('session_listener')->getArgument(1));
81-
$this->assertEquals('session.storage.native_file', (string) $container->getAlias('session.storage'));
81+
$this->assertEquals('session.storage.native', (string) $container->getAlias('session.storage'));
82+
$this->assertEquals('session.handler.native_file', (string) $container->getAlias('session.handler'));
8283

8384
$options = $container->getParameter('session.storage.options');
8485
$this->assertEquals('_SYMFONY', $options['name']);

0 commit comments

Comments
 (0)
0