php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60565 $_SERVER['REQUEST_TIME'] is now a float but lacks a digit in Apache2 SAPI
Submitted: 2011-12-19 17:09 UTC Modified: 2011-12-19 17:45 UTC
From: lolautruche at gmail dot com Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 5.4SVN-2011-12-19 (snap) OS: Mac OS X 10.7.2 (Lion)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lolautruche at gmail dot com
New email:
PHP Version: OS:

 

 [2011-12-19 17:09 UTC] lolautruche at gmail dot com
Description:
------------
As of PHP 5.4, $_SERVER['REQUEST_TIME'] is no longer an int, but a float.
However, using Apache 2 SAPI, this server variable only have 3 decimal digits. 
This make DateTime::__construct() throw an exception :

Fatal error: Uncaught exception 'Exception' with message 
'DateTime::__construct(): Failed to parse time string (@1324314320.916) at 
position 12 (9): Unexpected character' in /Users/lolautruche/workspace/test.php 
on line 3

As a comparison, FPM and built-in server defines 4 decimal digits, which is 
valid.

This might affect Apache 1 SAPI as well.
This also might be related to #55733

Test script:
---------------
<?php
var_dump( $_SERVER['REQUEST_TIME'] ); // Displays a float with 3 decimal digits with Apache2, 4 with FPM/built-in server
$date = new DateTime( '@' . $_SERVER['REQUEST_TIME'] );
var_dump( $date );

Expected result:
----------------
$_SERVER['REQUEST_TIME'] should always have 4 decimal digits.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-19 17:45 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

With 4 digits it also doesn't get parsed properly... as it will see those 4 digits as a year. You just shouldn't pass a float as a timestamp, as timestamps in PHP are integer seconds since the epoch. This is not a bug in PHP.
 [2011-12-19 17:45 UTC] derick@php.net
-Status: Open +Status: Bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 20:01:32 2024 UTC