Skip to content

Commit

Permalink
fix: use Drupal getRequestTime where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
pgautier404 committed Oct 12, 2023
1 parent 1d1a7a0 commit e470bd4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/MomentoCacheBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ public function get($cid, $allow_invalid = FALSE)
private function valid($item) {
// TODO: see https://www.drupal.org/project/memcache/issues/3302086 for discussion of why I'm using
// $_SERVER instead of Drupal::time() and potential suggestions on how to inject the latter for use here.
// $requestTime = \Drupal::time()->getRequestTime();
$requestTime = $_SERVER['REQUEST_TIME'];
try {
$requestTime = \Drupal::time()->getRequestTime();
} catch (ContainerNotInitializedException $e) {
$requestTime = $_SERVER['REQUEST_TIME'];
}
$isValid = TRUE;
if ($item->expire != CacheBackendInterface::CACHE_PERMANENT && $item->expire < $requestTime) {
$item->valid = FALSE;
Expand Down

0 comments on commit e470bd4

Please sign in to comment.