Skip to content

Commit 6710863

Browse files
author
Saem Ghani
committed
[FrameworkBundle] Fixed OutOfBoundException when session handler_id is null
When a null is provided for framework.session.handler_id the FrameworkExtension attempts to set the session storage to null for the 'session.storage.php_bridge' by altering the second argument. According to the session.xml service definition, there is no second argument, and it is in fact the first (read, 0 index) argument that should be changed.
1 parent 18e8733 commit 6710863

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
319319
if (null == $config['handler_id']) {
320320
// Set the handler class to be null
321321
$container->getDefinition('session.storage.native')->replaceArgument(1, null);
322-
$container->getDefinition('session.storage.php_bridge')->replaceArgument(1, null);
322+
$container->getDefinition('session.storage.php_bridge')->replaceArgument(0, null);
323323
} else {
324324
$container->setAlias('session.handler', $config['handler_id']);
325325
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'session' => array(
5+
'handler_id' => null,
6+
),
7+
));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:framework="http://symfony.com/schema/dic/symfony"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
8+
9+
<framework:config>
10+
<framework:session handler-id="null"/>
11+
</framework:config>
12+
</container>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
session:
3+
handler_id: null

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ public function testSession()
114114
$this->assertEquals('/path/to/sessions', $container->getParameter('session.save_path'));
115115
}
116116

117+
public function testNullSessionHandler()
118+
{
119+
$container = $this->createContainerFromFile('session');
120+
121+
$this->assertTrue($container->hasDefinition('session'), '->registerSessionConfiguration() loads session.xml');
122+
$this->assertNull($container->getDefinition('session.storage.native')->getArgument(1));
123+
$this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0));
124+
}
125+
117126
public function testTemplating()
118127
{
119128
$container = $this->createContainerFromFile('full');

0 commit comments

Comments
 (0)