Skip to content

Commit fabd09b

Browse files
Merge branch '6.0' into 6.1
* 6.0: Fix tests Bump Symfony version to 6.0.7 Update VERSION for 6.0.6 Update CHANGELOG for 6.0.6 Bump Symfony version to 5.4.7 Update VERSION for 5.4.6 Update CHANGELOG for 5.4.6 Bump Symfony version to 4.4.40 Update VERSION for 4.4.39 Update CONTRIBUTORS for 4.4.39 Update CHANGELOG for 4.4.39 [redis-messenger] remove undefined array key warnings do not pass DBAL connections to PDO adapters [HttpFoundation] Fix PHP 8.1 deprecation in isNotModified
2 parents 2622bc7 + a000fcf commit fabd09b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Response.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,7 @@ public function isNotModified(Request $request): bool
10641064
$lastModified = $this->headers->get('Last-Modified');
10651065
$modifiedSince = $request->headers->get('If-Modified-Since');
10661066

1067-
if ($ifNoneMatchEtags = $request->getETags()) {
1068-
$etag = $this->getEtag();
1067+
if (($ifNoneMatchEtags = $request->getETags()) && (null !== $etag = $this->getEtag())) {
10691068
if (0 == strncmp($etag, 'W/', 2)) {
10701069
$etag = substr($etag, 2);
10711070
}

Tests/ResponseTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified()
275275
$this->assertFalse($response->isNotModified($request));
276276
}
277277

278+
public function testIfNoneMatchWithoutETag()
279+
{
280+
$request = new Request();
281+
$request->headers->set('If-None-Match', 'randomly_generated_etag');
282+
283+
$this->assertFalse((new Response())->isNotModified($request));
284+
285+
// Test wildcard
286+
$request = new Request();
287+
$request->headers->set('If-None-Match', '*');
288+
289+
$this->assertFalse((new Response())->isNotModified($request));
290+
}
291+
278292
public function testIsValidateable()
279293
{
280294
$response = new Response('', 200, ['Last-Modified' => $this->createDateTimeOneHourAgo()->format(\DATE_RFC2822)]);

0 commit comments

Comments
 (0)