Problem/Motivation

This issue was originally created to address a change in PHP 5.4 where $_SERVER['REQUEST_TIME'] was changed from an int to a float. This change was backed out (can't find definitive reference for this), and REQUEST_TIME_FLOAT was introduced instead. This means that this patch is not needed anymore.

Proposed resolution

  • Revert this patch.
  • Remove explicits casts of REQUEST_TIME to int not using the define()

Remaining tasks

Revert this patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Original Issue

Starting with PHP 5.4.0, $_SERVER['REQUEST_TIME'] is a float with microseconds. This change has probably not be considered carefully enough, because most of the rest of PHP gets really confused by float timestamps:

$ php5 -r 'echo $_SERVER["REQUEST_TIME"]; var_export(date_create("@" . $_SERVER["REQUEST_TIME"]));'
1309862915.4905
DateTime::__set_state(array(
   'date' => '4946-07-05 10:48:35',
   'timezone_type' => 1,
   'timezone' => '+00:00',
))

I suggest we just cast our own REQUEST_TIME constant to (int).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Damien Tournoud’s picture

Status: Active » Needs review
FileSize
862 bytes
sun’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

Looks good.

The cast to integer is safe here, since we only have 4 decimals:

> php -r "var_dump((int) 99.9999);"
int(99)

> php -r "var_dump((int) 99.999999999999999);"
int(100)
Dries’s picture

Status: Reviewed & tested by the community » Fixed

How weird to provide that information as a float instead of, say, microseconds. What were they smoking?

Committed to 8.x. Thanks DamZ.

Damien Tournoud’s picture

Issue tags: +PHP 5.4
sun’s picture

Version: 8.x-dev » 7.x-dev
Status: Fixed » Reviewed & tested by the community
sun’s picture

#1: 1209470-request-time-float.patch queued for re-testing.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Wow, what are they smoking is right. ;P

Committed and pushed to 7.x. Thanks!

Status: Fixed » Closed (fixed)

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

rjbrown99’s picture

Version: 7.x-dev » 6.x-dev
Status: Closed (fixed) » Patch (to be ported)

Not to kick a dying dog, but if the D8 release is scheduled for fall 2013 that means that Drupal 6 will be supported until that time as well. Since we are already at PHP 5.4.0 release candidate 8, I am assuming that a final 5.4 release will be out long before that time. I am therefore concluding that Drupal 6 and PHP 5.4 will coexist as supported during the same time period.

Given that thought, does this need a backport? And, if the answer is yes, do we also need to backport #305645: DX: replace $_SERVER['REQUEST_TIME'] with a define which creates the constant REQUEST_TIME and #302763: Remove time() so it's easier to fix? This could also be an issue in contrib if people are using $_SERVER["REQUEST_TIME"].

If the answer is no feel free to re-close this and tell me I'm off-base. If you would like me to attempt to roll these three issues together into a 6.x patch, I'd also be happy to do that.

Damien Tournoud’s picture

Version: 6.x-dev » 8.x-dev
Status: Patch (to be ported) » Needs work

The PHP core team identified that this was an unwelcome change and decided to make REQUEST_TIME a int again. We can remove the cast from 8.x and 7.x.

sun’s picture

@Damien: A huge THANKS to you for tracking changes and getting involved upstream in the PHP project!

--
For D8, I believe this also means that we can change the define into a const.

Damien Tournoud’s picture

Issue summary: View changes
jhedstrom’s picture

Issue summary: View changes
Issue tags: -PHP 5.4 +Needs issue summary update

Needs an issue summary update since the issue was fixed, but this remains open to revert the change as explained in #10.

mpdonadio’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
dawehner’s picture

Status: Needs review » Needs work
Issue tags: +Novice

Good to know, this basically allows us to get rid of a couple of annoying (int) bits

anchal29’s picture

Assigned: Unassigned » anchal29
Status: Needs work » Needs review
FileSize
728 bytes

Reverted the patch.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 15: Request-time-int-1209470-15.patch, failed testing.

mpdonadio’s picture

That's weird, https://www.drupal.org/pift-ci-job/147014 shows nothing but passes. Triggering manual retest before I reset RTBC.

mpdonadio’s picture

Assigned: anchal29 » Unassigned
Status: Needs work » Reviewed & tested by the community

Retest of #15 is green. Back to RTBC.

mpdonadio’s picture

Assigned: Unassigned » mpdonadio
Status: Reviewed & tested by the community » Needs work

Actually, I am setting this back to NW to address some other casts that crept in.

mpdonadio’s picture

Assigned: mpdonadio » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
FileSize
13.42 KB
12.71 KB

Did some greps, and think this catches all uses of the int cast where the REQUEST_TIME is grabbed from $_SERVER directly, or via the request.

gnuget’s picture

This looks good to me, I think we can move this to RTBC

Thanks.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • Dries committed bfaf647 on 8.3.x
    - Patch #1209470 by Damien Tournoud: Fixed REQUEST_TIME is a float with...

  • Dries committed bfaf647 on 8.3.x
    - Patch #1209470 by Damien Tournoud: Fixed REQUEST_TIME is a float with...

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • Dries committed bfaf647 on 8.4.x
    - Patch #1209470 by Damien Tournoud: Fixed REQUEST_TIME is a float with...

  • Dries committed bfaf647 on 8.4.x
    - Patch #1209470 by Damien Tournoud: Fixed REQUEST_TIME is a float with...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gnuget’s picture

I wonder if we should now use the Time service added on Drupal 8.3.x instead to cast to INT the REQUEST_TIME constant.

Munavijayalakshmi’s picture

Version: 8.3.x-dev » 8.2.x-dev
Assigned: Unassigned » Munavijayalakshmi
Status: Needs review » Needs work
Issue tags: +Needs reroll
Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
Status: Needs work » Needs review
FileSize
12.99 KB

Rerolled the patch.

Munavijayalakshmi’s picture

Issue tags: -Needs reroll
agomezmoron’s picture

Issue tags: +DevDaysSeville
agomezmoron’s picture

It worked for me but I queued an extra test for PHP 7 - there are some many users with PHP updated and we need to ensure it will not break anything

agomezmoron’s picture

Status: Needs review » Reviewed & tested by the community

After seeing with PHP7 works and it is not broken, so it is fine from my side.

mpdonadio’s picture

Version: 8.2.x-dev » 8.4.x-dev
Category: Bug report » Task
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

This needs to be against 8.4.x, and it doesn't apply. I also don't think this qualifies as a bug anymore.

mpdonadio’s picture

Status: Needs work » Closed (outdated)

Closing this to avoid the multiple-patch-on-same-issue-thing. New work should be on #2862477: Remove casts from REQUEST_TIME. I will get issue credits transferred over.