Skip to content

Commit 860edff

Browse files
authored
Merge pull request #447 from emodric/session_listener_regression
[1.3] when sessions are not enabled, the listener does not exist either
2 parents 5e9a1b2 + 16425d8 commit 860edff

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
1.3.15
5+
------
6+
7+
* Fix session_listener decoration when session is not enabled.
8+
49
1.3.14
510
------
611

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the FOSHttpCacheBundle package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOS\HttpCacheBundle\DependencyInjection\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
17+
/**
18+
* Remove the session listener decorator again if the application has no session listener.
19+
*
20+
* This will happen on some APIs when the session system is not activated.
21+
*/
22+
class SessionListenerRemovePass implements CompilerPassInterface
23+
{
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function process(ContainerBuilder $container)
28+
{
29+
if ($container->has('session_listener')) {
30+
return;
31+
}
32+
33+
$container->removeDefinition('fos_http_cache.user_context.session_listener');
34+
}
35+
}

FOSHttpCacheBundle.php

+5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
use FOS\HttpCacheBundle\DependencyInjection\Compiler\SecurityContextPass;
1616
use FOS\HttpCacheBundle\DependencyInjection\Compiler\TagSubscriberPass;
1717
use FOS\HttpCacheBundle\DependencyInjection\Compiler\HashGeneratorPass;
18+
use FOS\HttpCacheBundle\DependencyInjection\Compiler\SessionListenerRemovePass;
1819
use Symfony\Component\DependencyInjection\ContainerBuilder;
1920
use Symfony\Component\HttpKernel\Bundle\Bundle;
21+
use Symfony\Component\HttpKernel\Kernel;
2022

2123
class FOSHttpCacheBundle extends Bundle
2224
{
@@ -29,5 +31,8 @@ public function build(ContainerBuilder $container)
2931
$container->addCompilerPass(new SecurityContextPass());
3032
$container->addCompilerPass(new TagSubscriberPass());
3133
$container->addCompilerPass(new HashGeneratorPass());
34+
if (version_compare(Kernel::VERSION, '3.4', '>=')) {
35+
$container->addCompilerPass(new SessionListenerRemovePass());
36+
}
3237
}
3338
}

0 commit comments

Comments
 (0)