File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
app/code/Magento/PageCache
Test/Unit/Model/App/Response Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,7 @@ public function beforeSendResponse(HttpResponse $subject)
4343
4444 $ currentVary = $ this ->context ->getVaryString ();
4545 $ varyCookie = $ this ->request ->get (HttpResponse::COOKIE_VARY_STRING );
46- if ($ currentVary !== $ varyCookie ) {
47- //prevent caching with the old vary cookie
46+ if (isset ($ varyCookie ) && ($ currentVary !== $ varyCookie )) {
4847 $ subject ->setNoCacheHeaders ();
4948 }
5049 $ subject ->sendVary ();
Original file line number Diff line number Diff line change @@ -92,4 +92,16 @@ public function testBeforeSendResponseVaryMismatch()
9292
9393 $ this ->httpPlugin ->beforeSendResponse ($ responseMock );
9494 }
95+
96+ public function testBeforeSendResponseVaryNotSet ()
97+ {
98+ /** @var HttpResponse|MockObject $responseMock */
99+ $ this ->context ->expects ($ this ->any ())->method ('getVaryString ' )->willReturn ('currentVary ' );
100+ $ this ->request ->expects ($ this ->any ())->method ('get ' )->willReturn (null );
101+ /** @var HttpResponse|MockObject $responseMock */
102+ $ responseMock = $ this ->createMock (HttpResponse::class);
103+ $ responseMock ->expects ($ this ->never ())->method ('setNoCacheHeaders ' );
104+ $ responseMock ->expects ($ this ->once ())->method ('sendVary ' );
105+ $ this ->httpPlugin ->beforeSendResponse ($ responseMock );
106+ }
95107}
You can’t perform that action at this time.
0 commit comments