This repository was archived by the owner on Feb 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Sensio \Bundle \FrameworkExtraBundle \EventListener ;
13
13
14
+ use Sensio \Bundle \FrameworkExtraBundle \Configuration \Cache ;
14
15
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
15
16
use Symfony \Component \ExpressionLanguage \ExpressionLanguage ;
16
17
use Symfony \Component \HttpFoundation \Response ;
@@ -42,7 +43,8 @@ public function __construct()
42
43
public function onKernelController (KernelEvent $ event )
43
44
{
44
45
$ request = $ event ->getRequest ();
45
- if (!$ configuration = $ request ->attributes ->get ('_cache ' )) {
46
+ $ configuration = $ request ->attributes ->get ('_cache ' );
47
+ if (!$ configuration instanceof Cache) {
46
48
return ;
47
49
}
48
50
@@ -81,8 +83,9 @@ public function onKernelController(KernelEvent $event)
81
83
public function onKernelResponse (KernelEvent $ event )
82
84
{
83
85
$ request = $ event ->getRequest ();
86
+ $ configuration = $ request ->attributes ->get ('_cache ' );
84
87
85
- if (!$ configuration = $ request -> attributes -> get ( ' _cache ' ) ) {
88
+ if (!$ configuration instanceof Cache ) {
86
89
return ;
87
90
}
88
91
Original file line number Diff line number Diff line change @@ -50,6 +50,16 @@ public function testWontReassignResponseWhenNoConfigurationIsPresent()
50
50
$ this ->assertSame ($ response , $ this ->event ->getResponse ());
51
51
}
52
52
53
+ public function testIgnoreUnknownCacheAttribute ()
54
+ {
55
+ $ response = $ this ->event ->getResponse ();
56
+
57
+ $ this ->request ->attributes ->set ('_cache ' , new \stdClass ());
58
+
59
+ $ this ->assertNull ($ this ->listener ->onKernelResponse ($ this ->event ));
60
+ $ this ->assertSame ($ response , $ this ->event ->getResponse ());
61
+ }
62
+
53
63
public function testResponseIsPublicIfSharedMaxAgeSetAndPublicNotOverridden ()
54
64
{
55
65
$ request = $ this ->createRequest (new Cache ([
You can’t perform that action at this time.
0 commit comments