Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 924b5ba

Browse filesBrowse files
committed
Merge branch '4.4' into 5.4
* 4.4: [HttpFoundation] Fix PHP 8.1 deprecation in isNotModified
2 parents e091d74 + 3cea8e7 commit 924b5ba
Copy full SHA for 924b5ba

File tree

Expand file treeCollapse file tree

2 files changed

+15
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-2
lines changed

‎src/Symfony/Component/HttpFoundation/Response.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Response.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,7 @@ public function isNotModified(Request $request): bool
10881088
$lastModified = $this->headers->get('Last-Modified');
10891089
$modifiedSince = $request->headers->get('If-Modified-Since');
10901090

1091-
if ($ifNoneMatchEtags = $request->getETags()) {
1092-
$etag = $this->getEtag();
1091+
if (($ifNoneMatchEtags = $request->getETags()) && (null !== $etag = $this->getEtag())) {
10931092
if (0 == strncmp($etag, 'W/', 2)) {
10941093
$etag = substr($etag, 2);
10951094
}

‎src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,20 @@ public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified()
287287
$this->assertFalse($response->isNotModified($request));
288288
}
289289

290+
public function testIfNoneMatchWithoutETag()
291+
{
292+
$request = new Request();
293+
$request->headers->set('If-None-Match', 'randomly_generated_etag');
294+
295+
$this->assertFalse((new Response())->isNotModified($request));
296+
297+
// Test wildcard
298+
$request = new Request();
299+
$request->headers->set('If-None-Match', '*');
300+
301+
$this->assertFalse((new Response())->isNotModified($request));
302+
}
303+
290304
public function testIsValidateable()
291305
{
292306
$response = new Response('', 200, ['Last-Modified' => $this->createDateTimeOneHourAgo()->format(\DATE_RFC2822)]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.