Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8319c69

Browse files
committed
Apply (int) casts to safeguard against null values for max-age/s-maxage
1 parent 73a93bc commit 8319c69

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ public function add(Response $response)
8181
return;
8282
}
8383

84-
$this->storeRelativeAgeDirective('max-age', $response->headers->getCacheControlDirective('max-age'), $age);
85-
$sharedMaxAge = $response->headers->hasCacheControlDirective('s-maxage') ? $response->headers->getCacheControlDirective('s-maxage') : $response->headers->getCacheControlDirective('max-age');
84+
$maxAge = $response->headers->hasCacheControlDirective('max-age') ? (int) $response->headers->getCacheControlDirective('max-age') : null;
85+
$this->storeRelativeAgeDirective('max-age', $maxAge, $age);
86+
$sharedMaxAge = $response->headers->hasCacheControlDirective('s-maxage') ? (int) $response->headers->getCacheControlDirective('s-maxage') : $maxAge;
8687
$this->storeRelativeAgeDirective('s-maxage', $sharedMaxAge, $age);
8788

8889
$expires = $response->getExpires();

0 commit comments

Comments
 (0)