Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit3cea8e7

Browse files
committed
bug#45631 [HttpFoundation] Fix PHP 8.1 deprecation inResponse::isNotModified (HypeMC)
This PR was merged into the 4.4 branch.Discussion----------[HttpFoundation] Fix PHP 8.1 deprecation in `Response::isNotModified`| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets | -| License | MIT| Doc PR | -If an `If-None-Match` header is provided in the request and there's no `ETag` header in the response, the following deprecation notice occurs on PHP 8.1 in `Response::isNotModified`:```Deprecated: strncmp(): Passing null to parameter#1 ($string1) of type string is deprecated```Commits-------b909acf [HttpFoundation] Fix PHP 8.1 deprecation in isNotModified
2 parents6ef994c +b909acf commit3cea8e7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

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

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

1082-
if ($ifNoneMatchEtags =$request->getETags()) {
1083-
$etag =$this->getEtag();
1082+
if (($ifNoneMatchEtags =$request->getETags()) && (null !==$etag =$this->getEtag())) {
10841083
if (0 ==strncmp($etag,'W/',2)) {
10851084
$etag =substr($etag,2);
10861085
}

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

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

287+
publicfunctiontestIfNoneMatchWithoutETag()
288+
{
289+
$request =newRequest();
290+
$request->headers->set('If-None-Match','randomly_generated_etag');
291+
292+
$this->assertFalse((newResponse())->isNotModified($request));
293+
294+
// Test wildcard
295+
$request =newRequest();
296+
$request->headers->set('If-None-Match','*');
297+
298+
$this->assertFalse((newResponse())->isNotModified($request));
299+
}
300+
287301
publicfunctiontestIsValidateable()
288302
{
289303
$response =newResponse('',200, ['Last-Modified' =>$this->createDateTimeOneHourAgo()->format(\DATE_RFC2822)]);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp