Verified Commit 55bf7eed authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3112290 by Spokje, mondrake, mpdonadio, daffie, andypost, Kristen Pol,...

Issue #3112290 by Spokje, mondrake, mpdonadio, daffie, andypost, Kristen Pol, quietone, mallezie, alexpott: Replace REQUEST_TIME in procedural code

(cherry picked from commit 433f2ae0)
parent e4e25769
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@
 * Comments changed after this time may be marked new, updated, or read,
 * depending on their state for the current user. Defaults to 30 days ago.
 *
 * @todo Remove when https://www.drupal.org/node/1029708 lands.
 * @todo Remove when https://www.drupal.org/node/2006632 lands.
 */
define('COMMENT_NEW_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
define('COMMENT_NEW_LIMIT', ((int) $_SERVER['REQUEST_TIME']) - 30 * 24 * 60 * 60);

/**
 * Implements hook_help().
+1 −1
Original line number Diff line number Diff line
@@ -446,7 +446,7 @@ function file_cron() {
    $fids = Drupal::entityQuery('file')
      ->accessCheck(FALSE)
      ->condition('status', FileInterface::STATUS_PERMANENT, '<>')
      ->condition('changed', REQUEST_TIME - $age, '<')
      ->condition('changed', \Drupal::time()->getRequestTime() - $age, '<')
      ->range(0, 100)
      ->execute();
    $files = $file_storage->loadMultiple($fids);
+6 −3
Original line number Diff line number Diff line
@@ -20,8 +20,10 @@
 *
 * Entities changed within this time may be marked as new, updated, or read,
 * depending on their state for the current user. Defaults to 30 days ago.
 *
 * @todo Remove when https://www.drupal.org/node/2006632 lands.
 */
define('HISTORY_READ_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
define('HISTORY_READ_LIMIT', ((int) $_SERVER['REQUEST_TIME']) - 30 * 24 * 60 * 60);

/**
 * Implements hook_help().
@@ -109,16 +111,17 @@ function history_write($nid, $account = NULL) {
  }

  if ($account->isAuthenticated()) {
    $request_time = \Drupal::time()->getRequestTime();
    \Drupal::database()->merge('history')
      ->keys([
        'uid' => $account->id(),
        'nid' => $nid,
      ])
      ->fields(['timestamp' => REQUEST_TIME])
      ->fields(['timestamp' => $request_time])
      ->execute();
    // Update static cache.
    $history = &drupal_static('history_read_multiple', []);
    $history[$nid] = REQUEST_TIME;
    $history[$nid] = $request_time;
  }
}

+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ function template_preprocess_image_style_preview(&$variables) {
  $variables['style_name'] = $style->label();

  // Cache bypass token.
  $variables['cache_bypass'] = REQUEST_TIME;
  $variables['cache_bypass'] = \Drupal::time()->getRequestTime();

  // Sample image info.
  $sample_width = 160;
+2 −2
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ function locale_translation_batch_status_finished($success, $results) {
    if (!isset($results['failed_files']) && !isset($results['files'])) {
      \Drupal::messenger()->addStatus(t('Nothing to check.'));
    }
    \Drupal::state()->set('locale.translation_last_checked', REQUEST_TIME);
    \Drupal::state()->set('locale.translation_last_checked', \Drupal::time()->getRequestTime());
  }
  else {
    \Drupal::messenger()->addError(t('An error occurred trying to check available interface translation updates.'));
@@ -219,7 +219,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
function locale_translation_batch_fetch_finished($success, $results) {
  \Drupal::moduleHandler()->loadInclude('locale', 'inc', 'locale.bulk');
  if ($success) {
    \Drupal::state()->set('locale.translation_last_checked', REQUEST_TIME);
    \Drupal::state()->set('locale.translation_last_checked', \Drupal::time()->getRequestTime());
  }
  return locale_translate_batch_finished($success, $results);
}
Loading