Skip to content

Commit 13e8e64

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: Fix return type patching for list and class-string pseudo types [HttpKernel] [HttpCache] Don't throw on 304 Not Modified
2 parents 550c151 + 2b775e2 commit 13e8e64

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

HttpCache/AbstractSurrogate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreE
9595
try {
9696
$response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
9797

98-
if (!$response->isSuccessful()) {
98+
if (!$response->isSuccessful() && Response::HTTP_NOT_MODIFIED !== $response->getStatusCode()) {
9999
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode()));
100100
}
101101

Tests/HttpCache/EsiTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,15 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent()
221221
$this->assertEquals('bar', $esi->handle($cache, '/', '/alt', false));
222222
}
223223

224+
public function testHandleWhenResponseIsNotModified()
225+
{
226+
$esi = new Esi();
227+
$response = new Response('');
228+
$response->setStatusCode(304);
229+
$cache = $this->getCache(Request::create('/'), $response);
230+
$this->assertEquals('', $esi->handle($cache, '/', '/alt', true));
231+
}
232+
224233
protected function getCache($request, $response)
225234
{
226235
$cache = $this->getMockBuilder(HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock();

0 commit comments

Comments
 (0)