Problem/Motivation

We've deprecated REQUEST_TIME in favour of \Drupal::time() and the Time service but that has a hidden dependency on the Symfony HttpKernel (eg, \Drupal\Core\DrupalKernel::preHandle()) and the request being placed on the request stack.

Proposed resolution

Fallback sensibly when this is not available.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

N/a

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

alexpott’s picture

So in our REQUEST_TIME docs we say

/**
 * Time of the current request in seconds elapsed since the Unix Epoch.
 *
 * This differs from $_SERVER['REQUEST_TIME'], which is stored as a float
 * since PHP 5.4.0. Float timestamps confuse most PHP functions
 * (including date_create()).
 *
 * @see http://php.net/manual/reserved.variables.server.php
 * @see http://php.net/manual/function.time.php
 *
 * @deprecated in drupal:8.3.0 and is removed from drupal:10.0.0.
 *   Use \Drupal::time()->getRequestTime();
 *
 * @see https://www.drupal.org/node/2785211
 */
define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);

But there's zero evidence of the int cast being necessary - see https://3v4l.org/VKWSU

alexpott’s picture

alexpott’s picture

andypost’s picture

mpdonadio’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

RTBC assuming the precautionary PHP version tests pass.

Adjusting the IS. Since this is Component and not Core, it is really a Symfony thing and not DrupalKernel thing.

  • catch committed da21d14 on 9.0.x
    Issue #3113476 by alexpott, mpdonadio: Fallback when request is not...

  • catch committed e7e2c31 on 8.9.x
    Issue #3113476 by alexpott, mpdonadio: Fallback when request is not...

  • catch committed aae0478 on 8.8.x
    Issue #3113476 by alexpott, mpdonadio: Fallback when request is not...
catch’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Fixed

Committed da21d14 and pushed to 9.0.x. Thanks! Cherry-picked to 8.9.x and 8.8.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.