[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.
This commit is contained in:
Saem Ghani 2013-06-07 15:05:01 -07:00
parent df0a02dc10
commit e3561ce49c
5 changed files with 32 additions and 1 deletions

View File

@ -319,7 +319,7 @@ class FrameworkExtension extends Extension
if (null == $config['handler_id']) {
// Set the handler class to be null
$container->getDefinition('session.storage.native')->replaceArgument(1, null);
$container->getDefinition('session.storage.php_bridge')->replaceArgument(1, null);
$container->getDefinition('session.storage.php_bridge')->replaceArgument(0, null);
} else {
$container->setAlias('session.handler', $config['handler_id']);
}

View File

@ -0,0 +1,7 @@
<?php
$container->loadFromExtension('framework', array(
'session' => array(
'handler_id' => null,
),
));

View File

@ -0,0 +1,12 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:session handler-id="null"/>
</framework:config>
</container>

View File

@ -0,0 +1,3 @@
framework:
session:
handler_id: null

View File

@ -114,6 +114,15 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals('/path/to/sessions', $container->getParameter('session.save_path'));
}
public function testNullSessionHandler()
{
$container = $this->createContainerFromFile('session');
$this->assertTrue($container->hasDefinition('session'), '->registerSessionConfiguration() loads session.xml');
$this->assertNull($container->getDefinition('session.storage.native')->getArgument(1));
$this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0));
}
public function testTemplating()
{
$container = $this->createContainerFromFile('full');