8000 bug #46769 [HttpKernel] Fix a PHP 8.1 deprecation notice in HttpCache… · wouterj/symfony@45db39c · GitHub
[go: up one dir, main page]

Skip to content

Commit 45db39c

Browse files
bug symfony#46769 [HttpKernel] Fix a PHP 8.1 deprecation notice in HttpCache (mpdude)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] Fix a PHP 8.1 deprecation notice in HttpCache | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | PHP 8.1 may trigger a deprecation notice `PHP Deprecated: abs(): Passing null to parameter #1 ($num) of type int|float is deprecated in .../symfony/http-kernel/HttpCache/HttpCache.php on line 721` The reason is that `$entry->getTtl()` may return `null` for cache entries where no freshness information is present. I think we would err on the safe side by not using stale-while-revalidate behaviour in this case. Commits ------- d0955c2 [HttpKernel] Fix a PHP 8.1 deprecation notice in HttpCache
2 parents 12c6dbf + d0955c2 commit 45db39c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ private function mayServeStaleWhileRevalidate(Response $entry): bool
718718
$timeout = $this->options['stale_while_revalidate'];
719719
}
720720

721-
return abs($entry->getTtl()) < $timeout;
721+
return abs($entry->getTtl() ?? 0) < $timeout;
722722
}
723723

724724
/**

0 commit comments

Comments
 (0)
0