Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 267a4f7

Browse files
committed
Added configuration validation
1 parent ff3b566 commit 267a4f7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,12 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
470470
$rootNode
471471
->children()
472472
->arrayNode('session')
473+
->validate()
474+
->ifTrue(function ($v) {
475+
return empty($v['handler_id']) && !empty($v['save_path']);
476+
})
477+
->thenInvalid('Session save path is ignored without a handler service')
478+
->end()
473479
->info('session configuration')
474480
->canBeEnabled()
475481
->children()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
2525
use Symfony\Component\Cache\Adapter\ProxyAdapter;
2626
use Symfony\Component\Cache\Adapter\RedisAdapter;
27+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
2728
use Symfony\Component\DependencyInjection\ChildDefinition;
2829
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
2930
use Symfony\Component\DependencyInjection\ContainerBuilder;
3031
use Symfony\Component\DependencyInjection\ContainerInterface;
3132
use Symfony\Component\DependencyInjection\Definition;
32-
use Symfony\Component\DependencyInjection\Exception\LogicException;
3333
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
3434
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
3535
use Symfony\Component\DependencyInjection\Reference;
@@ -477,7 +477,7 @@ public function testNullSessionHandler()
477477

478478
public function testNullSessionHandlerWithSavePath()
479479
{
480-
$this->expectException(LogicException::class);
480+
$this->expectException(InvalidConfigurationException::class);
481481
$this->createContainerFromFile('session_savepath');
482482
}
483483

0 commit comments

Comments
 (0)