From 985b057b41c64605b45fe712fc087d56b49bfa11 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Tue, 27 Feb 2024 21:06:16 +0000
Subject: [PATCH] Issue #3422973 by acbramley, dww, andypost: Replace remaining
 mentions of REQUEST_TIME in comments

---
 .../Drupal/Component/Datetime/TimeInterface.php    |  1 -
 .../lib/Drupal/Core/Asset/JsCollectionRenderer.php |  2 +-
 core/lib/Drupal/Core/Entity/entity.api.php         | 14 +++++++-------
 .../src/Kernel/UpdateDeleteFileIfStaleTest.php     |  3 ++-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/core/lib/Drupal/Component/Datetime/TimeInterface.php b/core/lib/Drupal/Component/Datetime/TimeInterface.php
index cedea4fe80da..9941208a48b9 100644
--- a/core/lib/Drupal/Component/Datetime/TimeInterface.php
+++ b/core/lib/Drupal/Component/Datetime/TimeInterface.php
@@ -20,7 +20,6 @@ interface TimeInterface {
    * This method can replace instances of
    * @code
    * $request_time = $_SERVER['REQUEST_TIME'];
-   * $request_time = REQUEST_TIME;
    * $request_time = $requestStack->getCurrentRequest()->server->get('REQUEST_TIME');
    * $request_time = $request->server->get('REQUEST_TIME');
    * @endcode
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
index d5b2191aa8c5..6c1ec18a4b01 100644
--- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
+++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
@@ -76,7 +76,7 @@ public function render(array $js_assets) {
     // A dummy query-string is added to filenames, to gain control over
     // browser-caching. The string changes on every update or full cache
     // flush, forcing browsers to load a new copy of the files, as the
-    // URL changed. Files that should not be cached get REQUEST_TIME as
+    // URL changed. Files that should not be cached get the request time as a
     // query-string instead, to enforce reload on every page request.
     $default_query_string = $this->assetQueryString->get();
 
diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php
index c6c3ec872b81..f3c6e1ae9c4f 100644
--- a/core/lib/Drupal/Core/Entity/entity.api.php
+++ b/core/lib/Drupal/Core/Entity/entity.api.php
@@ -572,7 +572,7 @@
  * @code
  * $fids = Drupal::entityQuery('file')
  *   ->condition('status', \Drupal\file\FileInterface::STATUS_PERMANENT, '<>')
- *   ->condition('changed', REQUEST_TIME - $age, '<')
+ *   ->condition('changed', \Drupal::time()->getRequestTime() - $age, '<')
  *   ->range(0, 100)
  *   ->execute();
  * $files = $storage->loadMultiple($fids);
@@ -1176,8 +1176,8 @@ function hook_entity_insert(\Drupal\Core\Entity\EntityInterface $entity) {
     ->fields([
       'type' => $entity->getEntityTypeId(),
       'id' => $entity->id(),
-      'created' => REQUEST_TIME,
-      'updated' => REQUEST_TIME,
+      'created' => \Drupal::time()->getRequestTime(),
+      'updated' => \Drupal::time()->getRequestTime(),
     ])
     ->execute();
 }
@@ -1199,8 +1199,8 @@ function hook_ENTITY_TYPE_insert(\Drupal\Core\Entity\EntityInterface $entity) {
   \Drupal::database()->insert('example_entity')
     ->fields([
       'id' => $entity->id(),
-      'created' => REQUEST_TIME,
-      'updated' => REQUEST_TIME,
+      'created' => \Drupal::time()->getRequestTime(),
+      'updated' => \Drupal::time()->getRequestTime(),
     ])
     ->execute();
 }
@@ -1222,7 +1222,7 @@ function hook_entity_update(\Drupal\Core\Entity\EntityInterface $entity) {
   // Update the entity's entry in a fictional table of all entities.
   \Drupal::database()->update('example_entity')
     ->fields([
-      'updated' => REQUEST_TIME,
+      'updated' => \Drupal::time()->getRequestTime(),
     ])
     ->condition('type', $entity->getEntityTypeId())
     ->condition('id', $entity->id())
@@ -1246,7 +1246,7 @@ function hook_ENTITY_TYPE_update(\Drupal\Core\Entity\EntityInterface $entity) {
   // Update the entity's entry in a fictional table of this type of entity.
   \Drupal::database()->update('example_entity')
     ->fields([
-      'updated' => REQUEST_TIME,
+      'updated' => \Drupal::time()->getRequestTime(),
     ])
     ->condition('id', $entity->id())
     ->execute();
diff --git a/core/modules/update/tests/src/Kernel/UpdateDeleteFileIfStaleTest.php b/core/modules/update/tests/src/Kernel/UpdateDeleteFileIfStaleTest.php
index 16bf30be1768..9813c41e3ab9 100644
--- a/core/modules/update/tests/src/Kernel/UpdateDeleteFileIfStaleTest.php
+++ b/core/modules/update/tests/src/Kernel/UpdateDeleteFileIfStaleTest.php
@@ -42,7 +42,8 @@ public function testUpdateDeleteFileIfStale() {
     $this->assertFalse($deleted);
     $this->assertFileExists($file_path);
 
-    // Set the maximum age to a number smaller than REQUEST_TIME - $filectime.
+    // Set the maximum age to a number smaller than
+    // \Drupal::time()->getRequestTime() - $filectime.
     $this->config('system.file')
       ->set('temporary_maximum_age', -100000)
       ->save();
-- 
GitLab