diff --git a/core/core.api.php b/core/core.api.php index 8db17509676b81235115dd625a74d4c04e02029a..a7662f8362a8ba4bcf8893e6a13cf9e71d4c2c51 100644 --- a/core/core.api.php +++ b/core/core.api.php @@ -188,7 +188,7 @@ * // Find out when cron was last run; the key is 'system.cron_last'. * $time = $state->get('system.cron_last'); * // Set the cron run time to the current request time. - * $state->set('system.cron_last', REQUEST_TIME); + * $state->set('system.cron_last', \Drupal::time()->getRequestTime()); * @endcode * * For more on the State API, see https://www.drupal.org/developing/api/8/state @@ -1919,10 +1919,11 @@ function hook_cron() { // Short-running operation example, not using a queue: // Delete all expired records since the last cron run. $expires = \Drupal::state()->get('mymodule.last_check', 0); + $request_time = \Drupal::time()->getRequestTime(); \Drupal::database()->delete('mymodule_table') ->condition('expires', $expires, '>=') ->execute(); - \Drupal::state()->set('mymodule.last_check', REQUEST_TIME); + \Drupal::state()->set('mymodule.last_check', $request_time); // Long-running operation example, leveraging a queue: // Queue news feeds for updates once their refresh interval has elapsed. @@ -1931,13 +1932,13 @@ function hook_cron() { foreach (Feed::loadMultiple($ids) as $feed) { if ($queue->createItem($feed)) { // Add timestamp to avoid queueing item more than once. - $feed->setQueuedTime(REQUEST_TIME); + $feed->setQueuedTime($request_time); $feed->save(); } } $ids = \Drupal::entityQuery('mymodule_feed') ->accessCheck(FALSE) - ->condition('queued', REQUEST_TIME - (3600 * 6), '<') + ->condition('queued', $request_time - (3600 * 6), '<') ->execute(); if ($ids) { $feeds = Feed::loadMultiple($ids); diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 8e3b73ad13efa397eac53796102bbc7c25fefab5..03af0c0a866525a6bc1a89db204a0645cefc14f4 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -252,7 +252,7 @@ function drupal_valid_test_ua($new_prefix = NULL) { } // The file properties add more entropy not easily accessible to others. $key = $private_key . filectime(__FILE__) . fileinode(__FILE__); - $time_diff = REQUEST_TIME - $time; + $time_diff = time() - $time; $test_hmac = Crypt::hmacBase64($check_string, $key); // Since we are making a local request a 600 second time window is allowed, // and the HMAC must match. diff --git a/core/includes/common.inc b/core/includes/common.inc index 97b36a3d15ac736e630a638693907149ee350629..dfcf090a52f0150095babcccb477e707d139490a 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -532,7 +532,7 @@ function drupal_flush_all_caches($kernel = NULL) { */ function _drupal_flush_css_js() { // The timestamp is converted to base 36 in order to make it more compact. - Drupal::state()->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); + Drupal::state()->set('system.css_js_query_string', base_convert(\Drupal::time()->getRequestTime(), 10, 36)); } /** diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 524c279fa780fc257f1fdb9cd3e3b6251a86a212..d3af268cc69133c56ecb52a4bc76aec4ee97b80e 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1054,11 +1054,12 @@ function install_display_output($output, $install_state) { $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer'); $response = $bare_html_page_renderer->renderBarePage($output, $output['#title'], 'install_page', $regions); + $request_time = \Drupal::time()->getRequestTime(); $default_headers = [ 'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT', - 'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME), + 'Last-Modified' => gmdate(DATE_RFC1123, $request_time), 'Cache-Control' => 'no-cache, must-revalidate', - 'ETag' => '"' . REQUEST_TIME . '"', + 'ETag' => '"' . $request_time . '"', ]; $response->headers->add($default_headers); $response->send(); @@ -1881,7 +1882,7 @@ function install_finished(&$install_state) { \Drupal::messenger()->addStatus($success_message); // Record when this install ran. - \Drupal::state()->set('install_time', $_SERVER['REQUEST_TIME']); + \Drupal::state()->set('install_time', \Drupal::time()->getRequestTime()); } /** diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 883c95f1d7cf255ae90aa3e6d6052eb3ec7a688c..e7bcbbb2055d47189e8b0bcf9053d856f4c4649a 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -1,25 +1,10 @@ parameters: ignoreErrors: - - - message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#" - count: 1 - path: includes/bootstrap.inc - - - - message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#" - count: 1 - path: includes/common.inc - - message: "#^Function format_size\\(\\) should return Drupal\\\\Core\\\\StringTranslation\\\\TranslatableMarkup but return statement is missing\\.$#" count: 1 path: includes/common.inc - - - message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#" - count: 2 - path: includes/install.core.inc - - message: "#^Function install_config_download_translations\\(\\) should return string but return statement is missing\\.$#" count: 1 @@ -2618,7 +2603,6 @@ parameters: count: 1 path: modules/system/tests/modules/service_provider_test/src/TestFileUsage.php - - message: "#^Access to an undefined property Drupal\\\\Tests\\\\system\\\\Functional\\\\Entity\\\\EntityListBuilderTest\\:\\:\\$webUser\\.$#" count: 1 @@ -3524,7 +3508,6 @@ parameters: count: 1 path: modules/workspaces/src/WorkspacePublisher.php - - message: "#^Access to an undefined property Drupal\\\\Tests\\\\workspaces\\\\Kernel\\\\EntityReferenceSupportedNewEntitiesConstraintValidatorTest\\:\\:\\$entityTypeManager\\.$#" count: 2 @@ -3540,11 +3523,6 @@ parameters: count: 5 path: profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php - - - message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#" - count: 1 - path: rebuild.php - - message: "#^Access to an undefined property Drupal\\\\BuildTests\\\\Framework\\\\BuildTestBase\\:\\:\\$phpFinder\\.$#" count: 1 diff --git a/core/phpstan.neon.dist b/core/phpstan.neon.dist index 543c5d50ef830cb0704480257a958d9a6b843db0..41bedcd7d32e6a06c659d113457294ad23dedeed 100644 --- a/core/phpstan.neon.dist +++ b/core/phpstan.neon.dist @@ -18,6 +18,9 @@ parameters: - ../*/node_modules/* - */tests/fixtures/*.php - */tests/fixtures/*.php.gz + # Skip Drupal 6 & 7 code. + - core/scripts/generate-d6-content.sh + - core/scripts/generate-d7-content.sh # Skip data files. - lib/Drupal/Component/Transliteration/data/*.php # Below extends on purpose a non existing class for testing. diff --git a/core/rebuild.php b/core/rebuild.php index 0c4d0d91c0839db07cd68e4dad61de281c91159b..4a6bc87a6d577d3c6ec96dced11b3473bf055b6e 100644 --- a/core/rebuild.php +++ b/core/rebuild.php @@ -38,7 +38,7 @@ if (Settings::get('rebuild_access', FALSE) || ($request->query->get('token') && $request->query->get('timestamp') && - ((REQUEST_TIME - $request->query->get('timestamp')) < 300) && + (($request->server->getInt('REQUEST_TIME') - $request->query->get('timestamp')) < 300) && hash_equals(Crypt::hmacBase64($request->query->get('timestamp'), Settings::get('hash_salt')), $request->query->get('token')) )) { // Clear user cache for all major platforms. diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh index 8b591f42b03770cb94f044cf22212e14b4207601..c7547b084243d97003bb9475b98760647d21c9fc 100644 --- a/core/scripts/generate-d7-content.sh +++ b/core/scripts/generate-d7-content.sh @@ -237,7 +237,7 @@ $node->status = intval($i / 2) % 2; $node->revision = 1; $node->promote = $i % 2; - $node->created = REQUEST_TIME + $i * 43200; + $node->created = $_SERVER['REQUEST_TIME'] + $i * 43200; $node->runtime = 0; $node->active = 1; $node->log = "added $i poll";